且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Java中将JSON对象转换为另一个JSON对象

更新时间:2023-01-08 12:11:36

一种替代方法是在Java中使用 JSON 框架,将您的JSON对象转换为Java,执行操作并生成新的JSON对象.

One alternative could be to use the JSON in Java framework to transform your JSON object into Java, perform operations and generate new JSON objects.

抱歉造成误会.

您真的应该选择推荐的框架,例如一个或@Alessio.尽管可以通过使用正则表达式来实现 ,但我个人还是建议反对,因为您要查找的嵌套和/或对象有所变化可以带来正则表达式本身的巨大变化.因此,尽管正则表达式可以更快地完成工作,但它可能不那么易读和可维护.

You should really go for a framework such as the one or @Alessio recommended. Although this should be possible to be done through the use of a regular expression, personally, I would recommend against it since a change in nesting and/or object you are looking for can bring about a big change in the regex itself. Thus, although a regex can get the job done quicker, it might not be as readable and maintainable.