[咨询] 添加接口调用post时数据库中json字段如何表示 #838
Description
Description
{{url}}/apijson/post
{
"ComplexPoly4OffsetLib" : {
"id" : null,
"uuid" : "0198d0a1-6302-70e5-adee-2a49d3446a8b",
"full_entity_key" : "Fdm20-Rpc-dev_760300368696180736_760299724456656962",
"from_sys" : "Fdm20-Rpc-dev",
"order_id" : null,
"order_code" : null,
"batch_id" : "760300368696180736",
"batch_code" : "YFceshi20250721001",
"entity_key" : "760299724456656962",
"entity_code" : "S250721990920-1001",
"duplicate" : null,
"poly" : {
"type" : "Shape"
},
"poly_md5" : "a07676153f6ffa7e8381de8614ec3d76",
"edge_count" : 12,
"edge_offset_list" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
"model_build_time" : "2025-07-21 10:16:54",
"import_time" : null,
"create_time" : null,
"update_time" : null
},
"tag": "ComplexPoly4OffsetLib"
}
请教一下,我想往数据库里新增一条记录,poly是mysql json字段类型, 发送的数据里,poly用{}来表示,数据库里写不进去,改用json字符串,可以写入进去,有没有比较好的办法,用字符串的方式,对前端不太友好
Activity
TommyLemon commentedon Aug 22, 2025
@maorx 可以加个关键词 @string 指定字段值转为字符串
"@string": "obj",
"obj": {}
作用和 @JSON 相反,参考引用它的代码都复制改下就能加上功能了
https://github.com/Tencent/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/JSONMap.java#L181-L183