Good morning,
I am looking to see how to implement a toJSON() function properly, escaping the information as needed. I know we have a proper fromJSON() in Arcade, but I am trying to feed a Webhook, and on rare occasions, the post fails due to what appears to be improperly escaped text strings.
"UrlEncode(textOrDictionary) -> Text" is different from JSON escaping.
TIA --
Solved! Go to Solution.
Ah right, I forget that Arcade doesn't really have its own Ideas section. I'd go with an Attribute Rules idea, that Arcade profile isn't available in Online so less-performant functions might at least get an implementation there perhaps.
If you need to implement this yourself you'll have to search for "JSON Stringify" and see if you can find an implementation to copy. Doing a serializer 100% to spec is a daunting task (and might not even be possible at an acceptable speed in Arcade) but it'll give you a lead on the type of data you need to parse to meet your requirements. Worst case you'll get some practice writing a pushdown automata in cut-down JavaScript, they don't teach you that in GIS school!
I'd also recommend posting an Idea to get ToJSON added to the function library, ESRI developers can bridge to the relevant runtime's JSON.stringify under the hood so I doubt it's an onerous request.
Also the usual caveat: make sure you validate any user data before you serialize, you don't want to risk webhook payload injection from malicious inputs!
I'd also recommend posting an Idea to get ToJSON added to the function library, ESRI developers can bridge to the relevant runtime's JSON.stringify under the hood so I doubt it's an onerous request.
Where else should this request be posted?
Ah right, I forget that Arcade doesn't really have its own Ideas section. I'd go with an Attribute Rules idea, that Arcade profile isn't available in Online so less-performant functions might at least get an implementation there perhaps.