JSON Definition Files for Entity Generation

Java
{
    "protocol": "protocolName",
    "name": "objectName", //Note: This is not used in iOS
    "entity": true, // If true then will add uuid field
    "fields": [
        {
            "name": "fieldName",
            "type": "STRING",
            "primaryKey": true
            "keys": [ "fieldKey" ]
            
        },
        {
            "name": "optionalfieldName",
            "type": "STRING",
            "nullable": true
            "keys": [ "optionalFieldKey", "anotherOptionalFieldKey" ]
            
        },
        { "name": "udcFieldName",
            "type": "UDC",
            "lookupEnabled": true
            "keys": [ "udcFieldKey", ]
            
        }
    ]
}

Item Descriptions

  • Protocol is the name of the base model that must be overridden

  • Name is for the object class implementation you want to generate

  • Entity denotes whether an ObjectBox class should be created for the class and if the annotation is added to the class

  • Fields is an array that contains all the fields that should be instantiated for this class. Each field includes:

    • name: The field name

    • type: One of INTEGER, STRING, DECIMAL, BOOL, URL, LONG, DATE, HASH, ENUM or UDC

    • keys: An array of the keys for the field (can be empty). Note that any primary key field should also have primaryKey : true

    • nullable: A boolean to indicate if the field is nullable or optional

    • Any Dates or Booleans are optional

    • Hash type Password hash are of different types between Android and iOS, therefore a type has been introduced specifically for that. The Hash type will be interpreted as String on Android side and as Int64 in iOS.

    • UDC type Fields with the type UDC can have a lookupEnabled property. If this property is set to true then additional fields will be created. If the lookupEnabled property is not set to true, then the field will simply be a normal String type field. Eg. If setting a field "status" as UDC with lookupEnabled to true, "status", "statusDescription" and "statusDescription2" will be created.