This blog post, part of a series about JSON data formats in the Contentstack SaaS headless CMS, describes how Contentstack represents complex field values. Complex fields are those that consist of JSON rather than scalar values.
Rather than storing zero or more simple, scalar values, complex field types store JSON, allowing storage of multiple values in complex structures.
The JSON rich text editor represents formatted text as a JSON structure that requires transformation to HTML or other presentation formats.
Excluding file fields and modular blocks fields, all of the other field types store scalars.
Below is an example value from a JSON rich text editor field containing the following formatted sentence.
The JSON rich text editor field type can contain bold text, italicized text, and underlined text.
"jsonrtefieldkey": { "uid": "21a6be7736eb487f8c11091bfb873796", "_version": 17, "attrs": {}, "children": [ { "type": "p", "attrs": {}, "uid": "d9cb38c3567f48cebe6a43e2f82415c6", "children": [ { "text": "The JSON rich text editor field type can contain " }, { "text": "bold text", "bold": true }, { "text": ", " }, { "text": "italicized text", "italic": true }, { "text": ", and " }, { "text": "underlined text", "underline": true }, { "text": "." } ] } ], "type": "doc" },
You may want to use SDKs and toolkits to convert these values to HTML.
You can implement custom field types that store JSON rather than scalars.
Modular blocks store JSON structures as field values.
Values of file fields appear as JSON structures in entries, but the JSON is stored in the asset rather than the entry that references it.
3 thoughts on “Contentstack JSON Data Formats: Complex Fields”