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
- For object columns use string key names: "settings-": ["theme", "language"].
- Remember the asymmetry: 'key+': [{'k': v}] merges objects; 'key-': ['k'] removes keys.
- 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
- Remember the asymmetry: key+ merges objects, key- removes String key names.
- Stringify numeric-looking keys before adding them to a key- array.
- Validate payload element types against the column's JSON kind before sending.
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
- PUT {}, {}/{} 必须为 JSONRequest {} !
- PUT {}, {} 类型为 {},不支持 Boolean, String, Number 等类型字段使用 'key+'
- 字符 {} 不合法!远程函数不允许指定类名!且必须为 function(key0,key1,...) 这种单函数格式!\
- {}:value 中value不合法!远程函数 key():{} 中的 arg 对应的值类型只能是 [Boolean,
- 子查询 {}/{}:{ range:value } 中 value 只能为 [ALL, ANY] 中的一个!
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/ebf067c393337c1e.
Report an issue: GitHub.