3. JSON examples
Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites
Using different display settings at admin/structure/types/manage/[content-type]/display one can change the generated JSON as desired.
Shown are several configurations based on the following example tables.

Feel free to check validity of each output and see the data structure by copy-pasting it into http://www.jsoneditoronline.org/.
NOTE
Best is to use the Themeless module to render a node's Tablefield and other text fields as JSON.
If you intend to use Views Datasource apply the latest patch on it of #2468325: For nesting JSON structures, allow certain fields to be designated for "raw passthrough".
Different configurations

The output is here rendered in PRETTY PRINT. In the JSON used to be consumed by a service that won't be the case.
[
{
"tabledata": [
{
"col_0": "Key",
"col_1": "Value"
},
{
"col_0": "Color",
"col_1": "Red"
},
{
"col_0": "Size",
"col_1": "XL"
}
],
"caption": ""
},
{
"tabledata": [
{
"col_0": "Human readable name",
"col_1": "Unicode character",
"col_2": "String with slashes",
"col_3": "Number"
},
{
"col_0": "Euro sign",
"col_1": "€",
"col_2": "https://en.wikipedia.org/wiki/%E2%82%AC",
"col_3": 8364
},
{
"col_0": "Latin Small Letter sharp S",
"col_1": "ß",
"col_2": "https://en.wikipedia.org/wiki/%C3%9F",
"col_3": 159
}
],
"caption": "Some description."
}
]Highlighted in yellow is indicated what options are added.

[
[
{
"Key": "Size",
"Value": "XL"
},
{
"Key": "Color",
"Value": "Red"
}
],
[
{
"Human readable name": "Latin Small Letter sharp S",
"Unicode character": "ß",
"String with slashes": "https://en.wikipedia.org/wiki/%C3%9F",
"Number": 159
},
{
"Human readable name": "Euro sign",
"Unicode character": "€",
"String with slashes": "https://en.wikipedia.org/wiki/%E2%82%AC",
"Number": 8364
}
]
]
[
[
{
"Color": {
"Value": "Red"
},
"Size": {
"Value": "XL"
}
}
],
[
{
"Euro sign": {
"Unicode character": "€",
"String with slashes": "https://en.wikipedia.org/wiki/%E2%82%AC",
"Number": 8364
},
"Latin Small Letter sharp S": {
"Unicode character": "ß",
"String with slashes": "https://en.wikipedia.org/wiki/%C3%9F",
"Number": 159
}
}
]
]
[
[
{
"Value": {
"Color": "Red",
"Size": "XL"
}
}
],
[
{
"Unicode character": {
"Euro sign": "€",
"Latin Small Letter sharp S": "ß"
},
"String with slashes": {
"Euro sign": "https://en.wikipedia.org/wiki/%E2%82%AC",
"Latin Small Letter sharp S": "https://en.wikipedia.org/wiki/%C3%9F"
},
"Number": {
"Euro sign": 8364,
"Latin Small Letter sharp S": 159
}
}
]
]Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion