<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to encode a JSON string in Arcade in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679603#M7672</link>
    <description>&lt;P&gt;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 &lt;A href="https://tc39.es/ecma262/multipage/structured-data.html#sec-json.stringify" target="_self"&gt;spec&lt;/A&gt; 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&amp;nbsp;&lt;EM&gt;that&amp;nbsp;&lt;/EM&gt;in GIS school!&lt;/P&gt;&lt;P&gt;I'd also recommend posting an Idea to get &lt;FONT face="courier new,courier"&gt;ToJSON&lt;/FONT&gt; 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.&lt;/P&gt;&lt;P&gt;Also the usual caveat: make sure you validate any user data&amp;nbsp;&lt;EM&gt;before&lt;/EM&gt; you serialize, you don't want to risk webhook payload injection from malicious inputs!&lt;/P&gt;</description>
    <pubDate>Fri, 23 Jan 2026 17:19:33 GMT</pubDate>
    <dc:creator>DavidSolari</dc:creator>
    <dc:date>2026-01-23T17:19:33Z</dc:date>
    <item>
      <title>How to encode a JSON string in Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679586#M7671</link>
      <description>&lt;P&gt;Good morning,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I am looking to see how to implement a toJSON() function properly, escaping the information as needed.&amp;nbsp; 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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "&lt;SPAN&gt;UrlEncode(textOrDictionary) -&amp;gt; Text" is different from JSON escaping.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;TIA --&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jan 2026 16:31:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679586#M7671</guid>
      <dc:creator>JeffSilberberg</dc:creator>
      <dc:date>2026-01-23T16:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to encode a JSON string in Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679603#M7672</link>
      <description>&lt;P&gt;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 &lt;A href="https://tc39.es/ecma262/multipage/structured-data.html#sec-json.stringify" target="_self"&gt;spec&lt;/A&gt; 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&amp;nbsp;&lt;EM&gt;that&amp;nbsp;&lt;/EM&gt;in GIS school!&lt;/P&gt;&lt;P&gt;I'd also recommend posting an Idea to get &lt;FONT face="courier new,courier"&gt;ToJSON&lt;/FONT&gt; 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.&lt;/P&gt;&lt;P&gt;Also the usual caveat: make sure you validate any user data&amp;nbsp;&lt;EM&gt;before&lt;/EM&gt; you serialize, you don't want to risk webhook payload injection from malicious inputs!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jan 2026 17:19:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679603#M7672</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2026-01-23T17:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to encode a JSON string in Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679608#M7673</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;I'd also recommend posting an Idea to get&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ToJSON&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;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.&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp; Where else should this request be posted?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jan 2026 17:25:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679608#M7673</guid>
      <dc:creator>JeffSilberberg</dc:creator>
      <dc:date>2026-01-23T17:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to encode a JSON string in Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679610#M7674</link>
      <description>&lt;P&gt;Ah right, I forget that Arcade doesn't really have its own Ideas section. I'd go with an &lt;A href="https://community.esri.com/t5/attribute-rules-ideas/idb-p/attribute-rules-ideas" target="_self"&gt;Attribute Rules&lt;/A&gt; idea, that Arcade profile isn't available in Online so less-performant functions might at least get an implementation there perhaps.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jan 2026 17:28:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679610#M7674</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2026-01-23T17:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to encode a JSON string in Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679714#M7675</link>
      <description>&lt;P data-unlink="true"&gt;If you're just looking for standard escaping, you can use Template Literals (&amp;nbsp;&lt;A href="https://developers.arcgis.com/arcade/guide/template-literals/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://developers.arcgis.com/arcade/guide/template-literals/&lt;/A&gt;&amp;nbsp;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample language-javascript"&gt;&lt;CODE&gt;&amp;gt;&amp;gt;&amp;gt; my_string = `hello\nworld\t\tthis is \r\n\t a new line`
&amp;gt;&amp;gt;&amp;gt; Console(my_string)
hello
world        this is 
     a new line&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need to encode the strings with html characters like &amp;amp;amp, you'll have to implement the converter yourself I believe. I frequently have to replace `&amp;amp;` with `&amp;amp;amp` in our label expressions using `Replace('&amp;amp;', '&amp;amp;amp')`&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You should also be able to use the ToCodePoint function if you need to encode unicode characters as escaped codepoints:&lt;/P&gt;&lt;PRE class="lia-code-sample language-javascript"&gt;&lt;CODE&gt;function encode(t){
  var chars = []
  var c
  for (var char in t) {
    c = t[char]
    if (ToCodePoint(c) &amp;gt;= 255){
      Push(chars, `\\u${ToCodePoint(c)}`)
    } else{
      Push(chars, c)
    }
  }
  return Concatenate(chars, '')
}

Console(encode('hello world 🌏'))

----------CONSOLE----------
&amp;gt;&amp;gt; hello world \u55356\u57103&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Jan 2026 07:02:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-encode-a-json-string-in-arcade/m-p/1679714#M7675</guid>
      <dc:creator>ShareUser</dc:creator>
      <dc:date>2026-01-24T07:02:07Z</dc:date>
    </item>
  </channel>
</rss>

