Java取JSON字符串中某个key对应的值

1. 定义一个JSON字符串,valueParam

{
    "valueSql": " and ( TMP.sczt in ('已配种','断奶','空怀','流产','返情','生产母猪','发情') ) and (  TMP.cxsj>35)",
    "view": null
}

2. 接受JSON字符串,并转成json对象

JSONObject valueParamJsonObject = JSON.parseObject(valueParam);

3. 获取json对象中某个key对应的值

String valueSql = valueParamJsonObject.getString("valueSql");

4. 结果

valueSql  = " and ( TMP.sczt in ('已配种','断奶','空怀','流产','返情','生产母猪','发情') ) and (  TMP.cxsj>35)";

你可能感兴趣的:(技术备注,Java后台,java,json)