Tencent/APIJSON · error · ConflictException

PUT {}, {}/{} 必须为 String 类型 !

Error message

PUT {}, {}/{} 必须为 String 类型 !

What it means

When 'key-' targets a JSONObject-valued column, elements of the argument array name the keys to delete from that object, so each element must be a String. A non-String element (number, boolean, object, array) triggers ConflictException '必须为 String 类型 !' with the key and index, since only string keys can be removed from a JSON object.

Source

Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java:771

					if (targetArray.contains(obj)) {
						throw new ConflictException("PUT " + path + ", " + key + "/" + i + " 已存在!");
					}
					targetArray.add(obj);
				} else {
					if (obj != null && obj instanceof Map == false) {
						throw new ConflictException("PUT " + path + ", " + key + "/" + i + " 必须为 JSONRequest {} !");
					}
					targetObj.putAll((Map) obj);
				}
			} else {
				if (targetArray != null) {
					if (targetArray.contains(obj) == false) {
						throw new NullPointerException("PUT " + path + ", " + key + "/" + i + " 不存在!");
					}
					targetArray.remove(obj);
				} else {
					if (obj instanceof String == false) {
						throw new ConflictException("PUT " + path + ", " + key + "/" + i + " 必须为 String 类型 !");
					}
					if (targetObj.containsKey(obj) == false) {
						throw new NullPointerException("PUT " + path + ", " + key + "/" + i + " 不存在!");
					}
					targetObj.remove(obj);
				}
			}
		}

		//add all 或 remove all >>>>>>>>>>>>>>>>>>>>>>>>>

		//PUT <<<<<<<<<<<<<<<<<<<<<<<<<
		sqlRequest.put(realKey, targetArray != null ? targetArray : JSON.toJSONString(targetObj)); // FIXME, SerializerFeature.WriteMapNullValue));
		//PUT >>>>>>>>>>>>>>>>>>>>>>>>>

	}

View on GitHub (pinned to 5284052872)

Solutions

  1. For object columns use string key names: "settings-": ["theme", "language"].
  2. Remember the asymmetry: 'key+': [{'k': v}] merges objects; 'key-': ['k'] removes keys.
  3. Stringify numeric-looking keys before sending.

Example fix

// before
{ "User": { "id": 1, "settings-": [ { "theme": "dark" } ] } }
// after
{ "User": { "id": 1, "settings-": [ "theme" ] } }
Defensive patterns

Strategy: type-guard

Validate before calling

Object current = fetchColumnValue(tableName, id, key);
if (current instanceof Map) {
  for (Object o : payload) if (!(o instanceof String)) throw new IllegalArgumentException(key + "- elements must be String key names for object columns");
}

Type guard

function removalPayloadValid(current: unknown, payload: unknown[]): boolean {
  const isObj = current !== null && typeof current === 'object' && !Array.isArray(current);
  return payload.every(p => !isObj || typeof p === 'string');
}

Prevention

When it happens

Trigger: PUT { "settings-": [1] } or { "settings-": [ { "theme": "dark" } ] } against a JSONObject column — correct form is "settings-": ["theme"].

Common situations: Using object/array elements for removal like for addition (key+ takes objects, key- takes key names); numeric keys serialized as JSON numbers instead of strings.

Related errors


AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14). Data as JSON: /api/errors/ebf067c393337c1e. Report an issue: GitHub.