JSON data as content input


#1

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?


#2

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


#3

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


#4

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


#5

Sorry this is not supported at the moment.