在下面的场景中,遍历名为“name”的逗号分隔 json 节点的最佳方法是什么?
GetStoredValue result =
dataManagerService.getStoredValue(itemId).checkedGet();
JsonNode node = mapper.readTree(result.getStoredString());
if (node.has("name")
&& node.has("price")
&& node.has("sku"))
{
//iterate through comma delimited "name" value and return the dataSources
//node: {"name":"test1,test2", "price":30, "sku":"123123123"}
//return:
//{"name":"test1", "price":30, "sku":"123123123"}
//{"name":"test2", "price":30, "sku":"123123123"}
ComboPooledDataSource dataSource = createDataSource(node);
dataSources.put(itemId, dataSource);
return dataSources.get(itemId);
}