JSON data as content input

Hi,

Does anyone have experience in configuring json data as input in a content type?

We are running Enonic XP as a headless cms and are in the need of defining different Redux actions that may be associated with for instance clicking on a button. The redux action will be a content type with input fields for configuring the action type and the payload. The question is, how would you implement the payload configuration? I was first thinking name-value-pairs, but the payload objects may be deep structures containing strings, numbers, booleans, arrays and nested objects. Therefore a UI for configuring all these fields one by one might be quite exhausting working with. My other option is having a textarea where the JSON representing the payload can be pasted directly. The controller code will then parse the json string and return as an object. This still seems a bit fragile and exposed for human mistakes.

Any ideas?

Hi Ingunn,

XP has custom input types in the backlog, but currently no ETA. I would investigate using a Widget (they can in 7.0 also live inside the Edit Mode), and use that to build a custom form with custom saving using the content library. The form could then use something like this http://jsoneditoronline.org/ to format and edit the JSON in a prettier way, and safely store away into XP as part of a content or elsewhere.

Hope that gives some ideas.

Best regards,
Bobby

1 Like

You could use JSON as input in a textarea, and maybe perform some validation in the preview to give editor instant feedback.

1 Like

Is it possible to perform validation in a Javascript function from the schema definition xml file?

Sorry this is not supported at the moment.