<?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: JSON engine add object ID to ALLDATA? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/JSON-engine-add-object-ID-to-ALLDATA/m-p/808448#M318784</link>
    <description>&lt;P&gt;Thanks Chris,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm willing to expect the provider to have a recordID field for each object.&amp;nbsp; But I don't think I should require them to enforce that the recordID is always the first name-value pair of an object.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If they give me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename myjson temp;

data _null_;
  file myjson ;
  put '[' ;
  put  '{"x":1,"ID":"001"}';
  put  ',' ;
  put  '{"ID":"002","x":10,"y":100}';
  put  ',' ;
  put  '{"z":1000,"ID":"003"}';
  put ']';
run;

libname myjson JSON fileref=myjson;

data want ;
  set myjson.alldata ;
  put (_all_)(=) ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That seems fair (since JSON objects are unordered), but the ALLDATA table loses the information about which attributes are associated with each ID. It returens:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;16   data want ;
17     set myjson.alldata ;
18     put (_all_)(=) ;
19   run ;

P=1 P1=x V=1 Value=1
P=1 P1=ID V=1 Value=001
P=1 P1=ID V=1 Value=002
P=1 P1=x V=1 Value=10
P=1 P1=y V=1 Value=100
P=1 P1=z V=1 Value=1000
P=1 P1=ID V=1 Value=003
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess for ALLDATA to be useful, I have to assume that attribute &lt;EM&gt;order&lt;/EM&gt; is meaningful, which seems odd, since a json object is an unordered set of name-value pairs.&amp;nbsp; So a JSON provider should be free to change the order of attributes anytime they want.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Q.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Apr 2022 22:17:43 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2022-04-18T22:17:43Z</dc:date>
    <item>
      <title>JSON engine add object ID to ALLDATA?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/JSON-engine-add-object-ID-to-ALLDATA/m-p/808437#M318778</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been playing with the JSON engine and the ALLDATA dataset it creates.&amp;nbsp; It seems... &lt;EM&gt;almost&lt;/EM&gt; useful?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like it's just a collection of name-value pairs, without any indication of a key such as a row number / object number / ordinal root / something that would allow you to identify the group of name-value pairs that came from a single object.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, given this JSON data with three objects:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename myjson temp;

data _null_;
  file myjson ;
  put '[' ;
  put  '{"x":1}';
  put  ',' ;
  put  '{"x":10, "y":100}';
  put  ',' ;
  put  '{"z":1000}';
  put ']';
run;

libname myj JSON fileref=myjson;

data want ;
  set myj.alldata ;
  put (_all_)(=) ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alldata has:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;345  data alldata ;
346    set myj.alldata ;
347    put (_all_)(=) ;
348  run ;

P=1 P1=x V=1 Value=1
P=1 P1=x V=1 Value=10
P=1 P1=y V=1 Value=100
P=1 P1=z V=1 Value=1000
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So looking at work.AllData, there is no object ID which would allow you to see with values came from which object.&amp;nbsp; You might assume that the data has two objects, when in fact it has three.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there some way to add an Object ID to alldata?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a simple case if I could assume that the first name-value pair in an object is always a unique ID, I wouldn't need the JSON engine to make an ObjectID for me.&amp;nbsp; But since&amp;nbsp; a JSON object has &lt;EM&gt;unordered&lt;/EM&gt; name-value pairs,&amp;nbsp; even if I know my data has an ID, it doesn't seem safe to assume that the first name-value pair will always be that ID.&amp;nbsp; Without an ObjectID I'm struggling to see how this ALLDATA table could be useful.&amp;nbsp; Am I missing some option?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;-Q.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 21:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/JSON-engine-add-object-ID-to-ALLDATA/m-p/808437#M318778</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-04-18T21:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: JSON engine add object ID to ALLDATA?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/JSON-engine-add-object-ID-to-ALLDATA/m-p/808443#M318782</link>
      <description>&lt;P&gt;It's up to whoever designs the JSON to add the extra object name/layer if it's important for the data. I've used the JSON engine with dozens of different services/sources and if there has ever been ambiguity, it's due to the construction of the original data and not the engine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A challenging source can come from GraphQL sources, which are usually designed to fill a UI component on a web page (think React) and not fill a 2-D data model, so you really need to know more about what to expect from the data in that case. I answered &lt;A href="https://stackoverflow.com/questions/71769504/extracting-multiple-values-having-same-path-in-json-using-json-map-in-sas" target="_self"&gt;a similar question on StackOverflow&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 21:59:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/JSON-engine-add-object-ID-to-ALLDATA/m-p/808443#M318782</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-04-18T21:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: JSON engine add object ID to ALLDATA?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/JSON-engine-add-object-ID-to-ALLDATA/m-p/808448#M318784</link>
      <description>&lt;P&gt;Thanks Chris,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm willing to expect the provider to have a recordID field for each object.&amp;nbsp; But I don't think I should require them to enforce that the recordID is always the first name-value pair of an object.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If they give me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename myjson temp;

data _null_;
  file myjson ;
  put '[' ;
  put  '{"x":1,"ID":"001"}';
  put  ',' ;
  put  '{"ID":"002","x":10,"y":100}';
  put  ',' ;
  put  '{"z":1000,"ID":"003"}';
  put ']';
run;

libname myjson JSON fileref=myjson;

data want ;
  set myjson.alldata ;
  put (_all_)(=) ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That seems fair (since JSON objects are unordered), but the ALLDATA table loses the information about which attributes are associated with each ID. It returens:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;16   data want ;
17     set myjson.alldata ;
18     put (_all_)(=) ;
19   run ;

P=1 P1=x V=1 Value=1
P=1 P1=ID V=1 Value=001
P=1 P1=ID V=1 Value=002
P=1 P1=x V=1 Value=10
P=1 P1=y V=1 Value=100
P=1 P1=z V=1 Value=1000
P=1 P1=ID V=1 Value=003
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess for ALLDATA to be useful, I have to assume that attribute &lt;EM&gt;order&lt;/EM&gt; is meaningful, which seems odd, since a json object is an unordered set of name-value pairs.&amp;nbsp; So a JSON provider should be free to change the order of attributes anytime they want.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Q.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 22:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/JSON-engine-add-object-ID-to-ALLDATA/m-p/808448#M318784</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-04-18T22:17:43Z</dc:date>
    </item>
  </channel>
</rss>

