Skip to content

Generates class objects from Json strings, along with methods to read/write these json strings with the classes

License

Notifications You must be signed in to change notification settings

HenrikPoulsen/Json2Class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Json2Class

This is a little tool written in Python 2.7 which generates class definitions from json files that are supplied to it. It also generates functions which can load and save these objects from json strings.

I like to have static typing since it makes it a lot easier to keep track of what is going on and having classes generated from the same source makes it easier to sync changes between frontend/backend if they use different languages.

If you make changes to the code I would love it if you submit a pull request so I can take in any improvements or fixes.

Requirements

View Getting Started for requirements and more details into how the tool is used

Example

Commandline

Json2Class.py Person.json --cs-out cs/Generated --py-out py/Generated --java-out java/Generated --namespace Generated

Person.json

{
  "name": "Incognito",
  "age": 32,
  "country": "Sweden",
  "family": [{
                "@name": "Person",
                "@skip_generate": "",
                "name": "Mom",
                "age": 57,
                "country": "Sweden",
                "family": []
            },
            {
                "@name": "Person",
                "@skip_generate": "",
                "name": "Dad",
                "age": 65,
                "country": "Sweden",
                "family": []
            }]
}

Results in

See Getting Started for more information

About

Generates class objects from Json strings, along with methods to read/write these json strings with the classes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published