简体   繁体   English

Java JSON编辑器/可视化器

[英]Java JSON editor / visualizer

I wrote an application that takes a JSON file as configuration. 我编写了一个使用JSON文件作为配置的应用程序。 Up to this point, I wrote the JSON config by hand. 到目前为止,我已经手工编写了JSON配置。 However, now I want to allow other users who are not familiar with JSON format to make their own configurations. 但是,现在我想允许不熟悉JSON格式的其他用户进行自己的配置。 There's only 3 types of objects that the configuration needs to store, but the user should be allowed to add multiple copies of these objects. 配置只需要存储3种类型的对象,但是应该允许用户添加这些对象的多个副本。 I want to write a configuration application where the user can press a button such as "Add Type A" and an object of type A is populated with default values and visualized so that the user can select properties and edit them. 我想编写一个配置应用程序,用户可以在其中按下“添加类型A”之类的按钮,并使用默认值填充并显示类型A的对象,以便用户可以选择属性并进行编辑。 I know how to write an application that does this, but I feel like I'm re-inventing the wheel. 我知道如何编写执行此操作的应用程序,但是我感觉自己正在重新发明轮子。 Does anyone know of an open-source Java library that I can use inside my config application to handle visualization and editing a JSON file? 有谁知道我可以在配置应用程序中使用的开源Java库来处理可视化和编辑JSON文件? If I'm approaching this from completely the wrong direction, please let me know. 如果我从完全错误的方向进行操作,请告诉我。

I'm tempted to say "don't fear to reinvent the wheel". 我很想说“别害怕重新发明轮子”。 But the fact is that there a bunch solutions available : 但是事实是有很多解决方案可用:

How do I convert an object to JSON representation (and vice-versa) 如何将对象转换为JSON表示 (反之亦然)
Java representation of JSON Object JSON对象的Java表示
Javascript to Java using JSON 使用JSON将Javascript转换为Java

among them, GSON looks fine. 其中, GSON看起来不错。

For my personal experience, Yaml turned out to be an appropriate solution. 根据我的个人经验, Yaml确实是一个合适的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM