mackie1908
I'm new here

CMS_INPUT_DOM $CMS_VALUE(DOMFIELD.toJSON)$

Hi First Spirit Community

I am new to FirstSPirit and the Community and wondered if anyone can help me with this problem. I am using 5.2 and I am trying to render a INPUT_DOM field into a valid JSON string using the toJSON method however the output is showing as

"de.espirit.firstspirit.access.editor.value.DomElementImpl@18aae286"

I can't understand what is going on at all as the documentation seems to state that I should be able to do this. Any help will be much appreciated.

Thanks

0 Kudos
3 Replies
pavone
I'm new here

Hey Daniel,

the important part in the documentation is

Handles Maps, Collections, Arrays, Numbers, Strings, Boolean, and Date. [...] Any object other than above will be converted using its 'toString()' value.

The toJSON method only works for the above data types. A CMS_INPUT_DOM returns a DomElement, hence toJSON delegates to toString.

Best regards

Tim

0 Kudos

Hi Tim

Thank you for getting back to me on this. After reading again I thought that would be the case. So if I wanted to achieve this in FirstSpirit am I better writing a custom snippet to take the formated HTML and convert it to a JSON compatible string with all the relevant characters being escaped etc?

Thanks

Danny

0 Kudos

Yes, I think that's the way to go.

0 Kudos