gpt4 book ai didi

java - 如何删除 json 格式中的特殊字符

转载 作者:行者123 更新时间:2023-11-30 06:43:33 25 4
gpt4 key购买 nike

这是我的 json 对象,我需要删除 json 对象前端和后端的“

"{"Employee" [{"id":111589,"firstName":"govind","lastName":"Lname1","company":"ABC","No1":1,"Test":null,"Test1":"name1"},
{"id":12345,"firstName":"name2","lastName":"Lname2","company":"ABC","No1":2,"Test":null,"Test1":"name2"},
{"id":14567,"firstName":"name3","lastName":"Lname3","company":"DEF","No1":3,"Test":null,"Test1":"name3"},
{"id":1212,"firstName":"govi","lastName":"l1","company":"Ac","No1":4,"Test":0,"Test1":"name4"},
{"id":1212,"firstName":"govi","lastName":"l1","company":"Ac","No1":5,"Test":0,"Test1":"name4"}]}"

最佳答案

您可以使用 String 类的 substring() 方法从开头和结尾删除 ",如下代码所示:

   String myjson="PUT YOUR JSON STRING HERE";
myjson= myjson.substring(1,myjson.length()-1);

关于java - 如何删除 json 格式中的特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44016093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com