JSONExport: JSON to Model


Now you do not need to Understand your JSON Structure and create your model manually. Here is a utility to convert your JSON into model to do that. You just need to paste your JSON in JSON field. First it will check it JSON is valid, then convert it into model. It will create different file for each class.

How to use JSONExport:

To use this tool, you first need to install it from here.
If you receive any alert like given below then open your System Preferences > Security & Privacy. 

Now click on Open Anyway. It will open this app in your system.

If you want to customise it you can download the source code from github. Open this in Xcode and run the application.

Now Open this app and enter your JSON or import .json file here:

It will convert your JSON into model according to selected language. It will give you given options for language.

These are supported Languages:

  1. Java for Android
  2. Java for Realm Android
  3. Java GSON for Android
  4. Swift Classes
  5. Swift Classes for SwiftyJSON library
  6. Swift Classes for Realm
  7. Swift – CoreData
  8. Swift Structures
  9. Swift Structures for Gloss
  10. Swift Mappable Classes for (Swift 3) ObjectMapper
  11. Swift Structures for Unbox
  12. Objective-C – iOS.
  13. Objective-C – MAC.
  14. Objective-C – CoreData.
  15. Objective-C for Realm iOS.

Here you can see your model in second window. It will name your class as property name and first class will be named as BaseClass. Here are some More option for you at bottom.

Root class name: To change base class name Enter your Class Name in Root class name field.

Classes Prefix: If you want to add some prefix before the class name, enter here.

Parent class name:  If you want to inherit your all model classes with a single class, Enter the name of class in that field.

There are more options:

  • If you want to create constructor in each model class, select Constructors Check box.
  • If you want to add Utility methods in model classes, then select  Utility Methods Check box.

Now your model is ready to use. Use just have to put it on right place. There is button “Save” in bottom right corner. Save your file in your project and use then.

Save your time and reduce efforts by using JSONExport. 🙂

Leave a Reply