java - Add a property to a json string with jackson json -
i storing json string text field in mysql. after insertion, want update json string , add mysql line id jackson json.
i have java string in json format
{ "thing":"val" } i'm looking add k/v without writing lines of codes.
to have :
{ "thing":"val" "mysqlid":10 } i can convert string jsonnode :
objectmapper mapper = new objectmapper(); jsonnode json = mapper.readtree( jsonstr); looking this
json.put("mysqlid",10); json.tostring(); then update in text field new json string in mysql
i can't make it. don't want use many class there simple way jackson?
try casting jsonnode objectnode , calling put on it.
Comments
Post a Comment