java访问Hashmap中存储的json有效负载值
我有一张地图
Map<String, Object> PayloadDb;
其中包含json负载 像
{ name: messenger ,version: 1.0.0,payload:{name=test,color=red, other values} } I am getting all these filed from DB table DB table has a column which stores CLOB - json After storing the record in Map it looks like:
My HashMap contains
[0] service
[1] version
[2] payload -
[0] key name
value test
[1] key color
red
等等
payload key of the hashmap contains key value pairs
我可以从地图上获取名称和版本
如何访问Map中存储的有效负载元素值
# 1 楼答案
您可以通过以下方式获得json的有效负载属性:
一旦获得了上面的有效负载映射,就可以通过
payload.get("name");
获得其属性确保在获取有效负载属性之前执行空检查