A tool to generate Apex code from JSON. You can use it to generate an Apex class either from a API resposne/request sample or from predefined schema.
- Sublime Text 3
- MavensMate is highly recommended. This plugin uses MM's Apex syntax highlight.
Since MavensMate requires ST 3, there will be no ST 2 support.
Install Package Control if you don't have it.
- Run
Install Package - Search for
JSON2Apex - Press
Enter
- Clone this repo to your Sublime Packages folder. To find it go to
Preferences -> Browse Packages(Sublime Text -> Preferences -> Browse Packageson Mac). - Restart Sublime if needed.
- Get a JSON response or request sample
- Open it in Sublime Text 3
- Using
Ctrl+Shit+P(or⌘+Shift+Pon Mac) findJSON2Apex: Convert sample to Apex - Press Enter
- You will see generated Apex code. Also a text input appears at the bottom of the buffer. Use this input to change generated class names quickly.
JSON sample schema can be found here YAML sample schema can be found here
- Create a schema.
- Use
JSON2Apex: Convert JSON schema to Apex(JSON2Apex: Convert YAML schema to Apexfor YAML schemas) command. (Ctrl+Shit+P(or⌘+Shift+Pon Mac) to find it) - Rename the class either manually or using a text input at the bottom of the buffer.
After renaming is over Sublime will select all the generated code for you to copy it anywhere you want.
- Swagger JSON to Apex REST Definition generation.
Apache 2.0 except for pyyaml.