JSON syntax for elements

JavaScript Object Notation

673d23dd68cf08627e90e16be103471a

Updated at November 15th, 2019

JSON syntax for elements

A Protobi project is specified by a JSON syntax that defines what elements exist and how they should be displayed. The primary document is an array containing one JSON object for each element.

In the simple example below, there are two elements, "Q1" representing a question in the survey, and "$root" representing the top of the survey document.

Here, "Q1" has an optional "format" attribute which specifies how raw values are to be formatted for display to the user, as an optional string title attribute.

[
    {
        "key": "Q1",
        "title": "Q1. What is your primary specialty?",
        "color":  "#9B6",
        "format": {
            "1": "Primary care",
            "2": "Allergy",
            "3": "Pulmonology",
            "4": "Otolaryngologist"
        }
    },
    {
        "key": "$root",
        "children": ["Q1"],
    }
]

We can extend the example to include a tab "profile" to be displayed to the user with a few defined admin variables:

[
    {
        "key": "Q1",
        "title": "Q1. What is your primary specialty?",
        "color":  "#9B6",
        "format": {
            "1": "Primary care",
            "2": "Allergy",
            "3": "Pulmonology",
            "4": "Otolaryngologist"
        }
    },
    {
        "key": "profile",
        "displayKey": "Profile",
        "children": [ "country", "source", "status"]
    },
    {
        "key": "status",
        "format": {
           "1": "Eligible",
           "2": "Invited",
           "3": "In progress",
           "4": "Terminated",
           "7": "Complete"
    },
    {
        "key": "$root",
        "children": ["profile", "Q1" ],
    }
]

The attribute "country" defines constituent elements. Just naming a child is enough to define and create a default element.

Here, "country" is listed in the children of element "$root". But there is no entry defined with a key "country", so Protobi will create a default element {"key": "country"}. That element will in turn look in the data for a column named "country". If it finds such a column, it will display the values directly.

Conversely, there is an entry with key "status" so Protobi will use that format to display the value in a human-readable format.

For any Protobi project you can see and edit the complete JSON specification by selecting the "Elements" tab under project settings. This is for advanced users only, so be very careful if editing this directly.

See our Protobi JSON Reference.pdf for a more detailed review of attributes and values, see the Element properties tutorial.

Was this article helpful?