<?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 How do I parse JSON in a Share Component? in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-parse-json-in-a-share-component/m-p/270381#M223511</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How do I access the Rhino JSON parser from webscript .js code that is part of a Share Component? Or access any other secure non-evaluating JSON parser for that matter.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Sep 2011 20:50:19 GMT</pubDate>
    <dc:creator>bjornd</dc:creator>
    <dc:date>2011-09-08T20:50:19Z</dc:date>
    <item>
      <title>How do I parse JSON in a Share Component?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-parse-json-in-a-share-component/m-p/270381#M223511</link>
      <description>How do I access the Rhino JSON parser from webscript .js code that is part of a Share Component? Or access any other secure non-evaluating JSON parser for that matter.</description>
      <pubDate>Thu, 08 Sep 2011 20:50:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-parse-json-in-a-share-component/m-p/270381#M223511</guid>
      <dc:creator>bjornd</dc:creator>
      <dc:date>2011-09-08T20:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I parse JSON in a Share Component?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-parse-json-in-a-share-component/m-p/270382#M223512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The only thing I found was using the JsonUtils from SpringSurf: &lt;/SPAN&gt;&lt;A href="http://www.springsurf.org/sites/1.0.0.M3/spring-webscripts/spring-webscripts-documentation/reference/html/js-index.html#js-index-jsonutils" rel="nofollow noopener noreferrer"&gt;http://www.springsurf.org/sites/1.0.0.M3/spring-webscripts/spring-webscripts-documentation/reference/html/js-index.html#js-index-jsonutils&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Sep 2011 07:44:29 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-parse-json-in-a-share-component/m-p/270382#M223512</guid>
      <dc:creator>sonata82</dc:creator>
      <dc:date>2011-09-09T07:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I parse JSON in a Share Component?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-parse-json-in-a-share-component/m-p/270383#M223513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The only thing I found was using the JsonUtils from SpringSurf: &lt;A href="http://www.springsurf.org/sites/1.0.0.M3/spring-webscripts/spring-webscripts-documentation/reference/html/js-index.html#js-index-jsonutils" rel="nofollow noopener noreferrer"&gt;http://www.springsurf.org/sites/1.0.0.M3/spring-webscripts/spring-webscripts-documentation/reference/html/js-index.html#js-index-jsonutils&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;Thanks for the suggestion, but jsonUtils.toObject doesn't work in Alfresco, it produces instead "&lt;/SPAN&gt;&lt;EM&gt;Expected collection or sequence. foo evaluated instead to freemarker.ext.beans.StringModel&lt;/EM&gt;&lt;SPAN&gt;".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the logged error when the "Object" is received by freemarker.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I use "eval()" instead, freemarker receives the intended object and everything works. But eval() is of course totally forbidden for the purposes of parsing JSON data in any serious project, so I was just wondering how everybody else deals with this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Sep 2011 19:44:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-parse-json-in-a-share-component/m-p/270383#M223513</guid>
      <dc:creator>bjornd</dc:creator>
      <dc:date>2011-09-09T19:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I parse JSON in a Share Component?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-i-parse-json-in-a-share-component/m-p/270384#M223514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The freemarker error message turned out to be a red herring. The object that was expected to be a JavaScript array was actually a Java object of the class &lt;/SPAN&gt;&lt;STRONG&gt;org.json.JSONArray&lt;/STRONG&gt;&lt;SPAN&gt; returned by &lt;/SPAN&gt;&lt;STRONG&gt;jsonUtils.toObject&lt;/STRONG&gt;&lt;SPAN&gt;. As documented, by the way, but still somewhat confusing. Java &lt;/SPAN&gt;&lt;STRONG&gt;JSONArray&lt;/STRONG&gt;&lt;SPAN&gt;s are not compatible with JavaScript arrays since element access is handled in a completely different way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I solved my problem by including Douglas Crockford's public-domain parser in my code. I found it via the link at the bottom of the page &lt;/SPAN&gt;&lt;A href="http://www.json.org/js" rel="nofollow noopener noreferrer"&gt;http://www.json.org/js&lt;/A&gt;&lt;SPAN&gt;. This is how I use it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;var connector = remote.connect("alfresco");&lt;BR /&gt;var response = connector.get("/my/service/url");&lt;BR /&gt;var data = json_parse(response + "");&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;The &lt;/SPAN&gt;&lt;STRONG&gt;response+""&lt;/STRONG&gt;&lt;SPAN&gt; thing on the last line converts the object returned by &lt;/SPAN&gt;&lt;STRONG&gt;connector.get&lt;/STRONG&gt;&lt;SPAN&gt; into a real JavaScript string. The original object is not a real JavaScript string, it lacks some of the standard string methods, which are used by the JSON parser.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Sep 2011 15:38:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-i-parse-json-in-a-share-component/m-p/270384#M223514</guid>
      <dc:creator>bjornd</dc:creator>
      <dc:date>2011-09-10T15:38:15Z</dc:date>
    </item>
  </channel>
</rss>

