Version v1.4.0 Released!
- Generate models from multiple JSON files in a folder at with one click!
- CLI interface - JSON to code directly from CLI, read more about how it works!
- Removed Cocoapods from the project due to CLI not being able to work with pods, switched to sub-modules.
- Minor bug fixes.
- Better installation directly from the repo with
make install
.
-
With CLI: Download the repo, run the script and you are good to go!
git clone https://github.com/insanoid/SwiftyJSONAccelerator.git cd SwiftyJSONAccelerator make install cd .. rm -rf SwiftyJSONAccelerator
-
Application Only: Download the .app (v1.4.0)
A swift model generator like the Objective-C JSONAccelerator. Formats and generates models for the given JSON and also breaks them into files making it easy to manage and share between several models.
The models that are generated depend on JSON object mapping libraries, currently the model can be generated to depend on any of the below mentioned mapping libraries:
Currently, the pattern is very similar to its Objective-C counterpart. It generates classes with following properties.
- Initalize with
JSON
(SwiftyJSON or ObjectMapper) or Initalize withAny
- Optional
NSCoding
compliance. - Convert object to
Dictionary
for description printing.
- Simple configurable interface for generation of file.
- Each class in the JSON is generated as a file.
- Click
Load Multiple JSONs with Config
to generate all possible models for given folder with JSON files, note this needs a.config.json
as this uses the CLI logic internally.
-
CLI simply works with the command
./swiftyjsonaccelerator generate
inside the folder with the JSON file. -
It merges the properties of multiple declarations of the same object (with the same key) in multiple JSON files into a single assimilated model.
-
it requires a
.config.json
file to function. The following are the customisable attributes:destination_path
: Path for the models to be saved at. (if not provided takes the path of the JSON files)author_name
: Name of the author for the file header.company_name
: Name of the company for the file header.construct_type
: if models should bestruct
orclass
. (Default isclass
)model_mapping_library
: Library to useMarshal
,SwiftyJSON
orObjectMapper
. (Default isSwiftyJSON
)support_nscoding
: IfNSCoding
protocol needs to be implemented. (Only works withclass
, default asfalse
)is_final_required
: Should the model be marked asfinal
. (Only works withclass
, default asfalse
)is_header_included
: Should the library header be included in the model file (default asfalse
)
-
See test.config.json is an example. The config file should be in the same folder as the models.
-
You can use
./swiftyjsonaccelerator generate -p path/to/json/files
to load JSON files at a particular location.
- Add a new type in
JSONMappingLibrary
in Constants.swift. - Follow the examples in Library-Extensions and create a struct implementing
ModelFile
. Follow the other extensions for SwiftyJSON and ObjectMapper, they tell you what all you can replace based on your libraries specification. You will also have to add the file to SwiftyJSONAccelerator-CLI/FileGenerator.swift as string unfortunately for now. - Do the necessary UI changes for the dropdown.
- Add tests for your library.
Version v1.3.0 Released!
- Serialisation keys moved into a struct for clarity.
- Minor fixes for Marshal and ObjectMapper.
- Generated comments now updated to the new Swift 3 Markup.
Version v1.2.0 Released!
- Now supports Marshal! One of the fastest JSONSerialisation class out there! (Read more)
- Set
class
asfinal
. init
marked asrequired
by default forclass
.
Download (v0.0.6), the older version of the project, please keep in mind it is no longer supported.
There is a lot more to do, follow the issues section, I usually try to follow up or keep the list updated with any new ideas which I plan to implement.
- Find solution for CLI not to have static text for templates in code.
- Add more comprehensive tests for CLI related code.
- Brew setup for the CLI.
- Adding support for better libraries mentioned here.
- Creating a better UI for the application.
Any suggestions regarding code quality of the app, generated code's quality, Swift related improvements and pull requests are all very welcome. Please make sure you submit the pull request to the next release branch and not the master branch.