Skip to content

Display a dictionary as a table

Make named prior annotations readable without turning each reviewer into a separate CSV column.

A Prior annotations table shows keys alex and sam with Role and Confidence values.A Prior annotations table shows keys alex and sam with Role and Confidence values.
Captured from this recipe’s downloadable configuration and sample data. Select image to enlarge.

Try this example: download the complete configuration and sample CSV. Open the configuration in MLabel, then load the CSV.

View the complete configuration
{
"$schema": "https://mlabel.vlad.gg/mlabel.schema.json",
"version": 2,
"network": {
"updateChecks": false,
},
"input": {
"fields": [
{
"name": "annotators",
"type": "map",
"display": {
"title": "Prior annotations",
"titlePosition": "above",
},
"values": {
"type": "object",
"fields": [
{
"name": "role",
"type": "text",
"display": "Role",
},
{
"name": "confidence",
"type": "number",
"display": "Confidence",
},
],
},
},
],
},
"output": {
"fields": [
{
"name": "verdict",
"type": "enum",
"widget": "radio",
"display": "Review decision",
"choices": [
{
"name": "pass",
"display": "Pass",
},
{
"name": "fail",
"display": "Fail",
},
],
},
],
},
}
View the sample CSV
annotators
"{""alex"":{""role"":""First reviewer"",""confidence"":0.8},""sam"":{""role"":""Second reviewer"",""confidence"":0.65}}"

Use a map when the keys vary between records. Here, reviewer names are keys, and each value is an object with role and confidence members.

The keys default to text. Use an object instead when the member names are a fixed part of the schema; use an array of objects when a record contains an ordered list of entries.

The relevant setting is in input.fields.0. The download above includes the surrounding configuration.

{
"name": "annotators",
"type": "map",
"display": {
"title": "Prior annotations",
"titlePosition": "above",
},
"values": {
"type": "object",
"fields": [
{
"name": "role",
"type": "text",
"display": "Role",
},
{
"name": "confidence",
"type": "number",
"display": "Confidence",
},
],
},
}

Open the sample and check that alex and sam appear in the key column. Their role and confidence values should line up in separate columns.

The map is source information, so it is read-only. Its keys identify entries; they are not choices in the answer form. To export the map, declare a matching output map with fill: { "kind": "copy" }.

Browse all illustrated recipes →