简体   繁体   中英

How do I copy and paste JSON into Eclipse and get a .java created?

As an Eclipse using client-side dev, my colleague just showed me the coolest features in Visual Studio where he copied a JSON string representing a single object and paste special into Visual Studio, then it automagically create a C# class complete with setters and getters. He then took a JSON string representing an array of objects and then did the same workflow. Visual Source save then derived the common fields in the collection and automagically created a C# class.

How do I do this in Eclipse? There is no such thing as Paste Special -> Parse JSON to Class in Eclipse that I know of.

protostuff could probably fit with your requirements, see http://code.google.com/p/protostuff/ it takes a special language describing the base data structure an produces tidy java classes with annotations.

Automagically deriving structured java classes from schema-less JSON sample data is IMHO a bad idea as you may miss optional fields that are not in your sample.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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