我目前在文件中的json可读格式是。
{"delete" : {
"_index" : "production",
"_type" : "listings",
"_id" : "f170321064",
"_version" : 6,
"result" : "deleted",
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 175987,
"_primary_term" : 1,
"status" : 200
}
}
如何转换如下
{"delete" : {"_index" : "production-cire","_type" : "listings","_id" : "424-l-81694-f1703210641700147","_version" : 6,"result" : "deleted","_shards" : {"total" : 1,"successful" : 1,"failed" : 0},"_seq_no" : 175987,"_primary_term" : 1,"status" : 200}}
答案 0 :(得分:0)
不确定您使用的是哪种语言,但我认为这对您有用。
let str = JSON.stringify({you_json})
答案 1 :(得分:0)
如果使用java或android:
字符串与您编写的完全相同,我不确定您是否可以将其转换为JSON。但如果你改变它有点像它后面给出你想要的东西:
String str="{" +
"delete : { " +
"_index : production, " +
"_type : listings, " +
"_id : f170321064, " +
"_version : 6, " +
"result : deleted, " +
"_shards : { " +
"total : 1, " +
"successful : 1, " +
"failed : 0" +
"}, " +
"_seq_no : 175987, " +
"_primary_term : 1, " +
"status : 200" +
"}" +
"}";
JSONObject obj= null;
try {
obj = new JSONObject(str);
System.out.println(obj.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
看输出:
{"delete":{"_index":"production","_type":"listings","_id":"f170321064","_version":6,"result":"deleted","_shards":{"total":1,"successful":1,"failed":0},"_seq_no":175987,"_primary_term":1,"status":200}}