Auto-generate plain old object models + custom JSON serialization/deserialization code from JSON schema definitions.
Js2model makes it easy to use JSON data as plain old Objective C, C++, or Python objects.
Js2model addresses the aforementioned shortcomings of typical JSON deserialization approaches by automatically generating model classes and serialization/deserialization code. Js2model uses the JSON Schema definition of your JSON data to generate source files which you include and build with the rest of your project.
The script is designed to target multiple output languages. Objective-C and C++ are supported out of the box. Future versions will add additional languages, as well as support for adding your own language templates.
You can review the documentation here
Chances are you do not have existing JSON Schema definitions for your JSON data. Theoretically, creating a schema is simply a matter of creating JSON file per the JSON Schema specifications. Realistically, creating a schema definition manually can be tedious and time intensive, depending on the complexity of your data. Luckily, there is a better way. GenSON is a script that will automatically generate JSON Schema from one or more JSON files. The resulting schema definitions may need some tweaking, but GenSON will save you considerable time and effort.
usage: js2model [-h] [-l LANG] [--prefix PREFIX] [--namespace NAMESPACE] [--rootname ROOTNAME] [--novalidate] [-o OUTPUT] [--implements IMPLEMENTS] [--super SUPER] [--import IMPORT_FILES] [-v] [--no-deserialize] [--no-dependencies] FILES [FILES ...] Generate native data models from JSON Schema definitions. positional arguments: FILES JSON Schema files for model generation optional arguments: -h, --help show this help message and exit -l LANG, --lang LANG Target language. Supported values: objc, cpp (default: objc) --prefix PREFIX prefix for class names (default: TR) --namespace NAMESPACE parent namespace for generated code (default: tr) --rootname ROOTNAME Class name for root schema object (default: base name of file) --novalidate Skip schema validation -o OUTPUT, --output OUTPUT Target directory of output files --implements IMPLEMENTS Comma separated list of interface(s)|protocol(s) supported by the generated classes --super SUPER Comma separated list of super classes. Generated classes inherit these --import IMPORT_FILES Comma separated list of files to @import for Objective C source files. -v, --verbose Print actions to STDOUT. --no-deserialize Do not generate deserialization code. Implies --no- dependencies. --no-dependencies Do not include dependencies in output.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size js2model-0.3.dev11.tar.gz (89.0 kB)||File type Source||Python version None||Upload date||Hashes View hashes|