What is JSON Cafe?

JSON Cafe is software development tool that helps you to generate model classes from JSON Object.

Technically JSON Cafe is template driven code generator that automates the creation of common application code for any language (Swift, Java, PHP, C#, VB etc.).

JSON Cafe includes many template for different languages and you even modify them or create your own to generate your code exactly you want it.

How it Works?

JSON Cafe Required JSON Object and Code Template to Generate Model Class.

JSON Object Contains Data and Code Template Contains the Code and Placeholders (tags eg. {{className}}, {{ type }} etc.) which is replaced by JSON Data

Available Tags (Placeholders)

{{ className }}Class NameRetun class name or root class in case of root node.
{{ nativeName }}Property NameReturn property name in camelCased
{{ jsonName }}json keyReturn Json key name of property in JSON Object
{{ type }}Peoperty DataTypeReturn language specific data type for Property (eg. int, float)
{{ isArray }}Return true/falsetrue/false indicates whether property is type of array or not, use in condition for type specific code in template
{{ isCustomClass }}Return true/falsetrue/false indicates whether property is custom type or not, use in condition for type specific code in template
{{ capitalizeJsonName }}Json keyReturn Json key name with first capital letter
{{ capitalizeNativeName }}Property NameReturn property name in with first capital letter
{{ capitalizeVarType }}Property DataTypeReturn property type with first capital letter
{{ cleanType }}Property DataTypeReturn property type without special character (eg [Int] -> Int)
{{ capitalizeCleanType }}Property DataTypeReturn clean property type with first capital letter
{{formatDate date "short" }}This will print current time. eg. June 20, 2018

{{formatDate date day="numeric" month="long" year="numeric" weekday="short"}}

Customize dateformat eg. Wed, June 20, 2018

{{ Header }}

Place Copyright header at specific position default at top position

{{#properties}}....{{/properties}} Iterate over class properties

properties tag iterate over all property of class object and render content of {{ TAGS }} between {{ #properties }} and {{ /properties }}

Control flow and Logical Operator {{#xif Expression }}...{{ /xif }}

{{ #xif expression}} to conditionally render a block.

following example to List all array type properties

        {{#xif "isArray"}}
        {{nativeName}} = {{cleanType}}() //iterate over all array elements in class object