Searching data / Working in the search window / Setting up a data table / Autoparser / Autoparse a JSON object
Autoparse a JSON object
The autoparser is able to detect JSON objects in unparsed events and extract individual key/value pairs in different columns if needed.
To do it, access the unparsed my.app
/ my.upload
table that contains the JSON objects and define the autoparser by following the steps in Autoparser. The value in the Type column will be automatically set to JSON object for the detected JSON objects. Click the dropdown selector to choose one of the available types:
- JSON object - This is the default option, and transforms each JSON object into a json type value.
- JSON split - Split the JSON object into different values, indicating the required depth level. The values in the list correspond to the available depth levels in the JSON objects. Learn more about this in the section below.
- String - This option transforms each JSON object into a string type value.
Split JSON objects
Choose the JSON split option in the Type column to divide your JSON object into different values. Once the option is selected, a second dropdown box appears to indicate the required depth level you want to apply.
After applying the autoparser, you will always get a column that shows the whole JSON objects (in json data type), whose name is the one you give in the Name field during the autoparsing creation process. Then, you will get as many additional columns as distinct keys you have in all your JSON objects, according to the given depth level. Not available levels in a specific JSON will be assigned null values. Learn more in the example below.
The order of the columns including the different JSON levels is random and may not follow the order of the JSON object.
Example
Let's see an example. We sent two events to Devo, each of them containing one of the following JSON objects:
{
"splitInt":1,
"childObj":
{
"childKey":"childVal",
"childKey2":"childVal2",
"childKey3":"childVal3",
"childkey4":
{
"newlevel1":1,
"newlevel2":2
}
}
}
and
{
"S1":
{
"S2":
{
"S2_child":
{
"int1": 4,
"int2": 5
}
}
}
}
In the autoparser configuration, we named the JSON object myJSON, and set the Type to JSON split.
Let's see what happens when we select different depth levels:
- If we select depth level 1, we will get the following columns (each column corresponds to a column in our Devo table):
myJSON | myJSON_splitInt | myJSON_childObj | myJSON_S1 |
---|---|---|---|
This cell will show the whole JSON object | 1 | {"childKey":"childVal","childKey2":"childVal2","childKey3":"childVal3","childkey4":{"newlevel1":1,"newlevel2":2}} | null |
This cell will show the whole JSON object | null | null | {"S2":{"S2_child":{"int1":4,"int2":5}}} |
- And this will be the result if we select depth level 2:
myJSON | myJSON_splitInt | myJSON_childObj_childkey | myJSON_childObj_childkey2 | myJSON_childObj_childkey3 | myJSON_childObj_childkey4 | myJSON_S1_S2 |
---|---|---|---|---|---|---|
This cell will show the whole JSON object | 1 | childVal | childVal2 | childVal3 | {"newlevel1":1,"newlevel2":2} | null |
This cell will show the whole JSON object | null | null | null | null | null | {"S2_child":{"int1":4,"int2":5}}} |