1.如何删除json里面的某个值
采用JsonPath里面delete方法,具体代码如下:
package testCode;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Predicate;
public class TestJsonPath {
public JSONObject delete(JSONObject j){
Configuration configuration = Configuration.builder().build();
JsonPath jsonPath = JsonPath.compile("$.store.book[0].title", new Predicate[0]);
j = jsonPath.delete(j, configuration);
return j;
}
public static void main(String args[]){
String s = "{\n" +
" \"store\": {\n" +
" \"book\": [\n" +
" {\n" +
" \"category\": \"reference\",\n" +