<?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: Reading JSON file with JSON LIBNAME engine in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725434#M225338</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I tried it and got the following error:&lt;/P&gt;&lt;P&gt;ERROR: JSON incorrect dans input à côté de la ligne 1 colonne 1: Encountered an illegal character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, we don't want the enconding to malfunction since the data is customer data we have to manipulate &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 11 Mar 2021 13:43:51 GMT</pubDate>
    <dc:creator>Pierre_L</dc:creator>
    <dc:date>2021-03-11T13:43:51Z</dc:date>
    <item>
      <title>Reading JSON file with JSON LIBNAME engine</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725308#M225258</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P&gt;I'm trying to read a json file i created while calling an API made by us.&lt;/P&gt;&lt;P&gt;The file is created fine but when i try to use the LIBNAME JSON Engine, it give me the following error message :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: JSON incorrect dans input à côté de la ligne 1 colonne 85993: Some code points did not transcode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did some research about "some code point did not transcode" and from what i've read, it's because the json file i'm trying to read is encoded in UTF-8; wich is true.&lt;/P&gt;&lt;P&gt;I've also read that i could put ENCONDING="UTF-8" (read example with UTF-8 in lowercase) : Got the same error message but not the same column number :&lt;/P&gt;&lt;P&gt;ERROR: JSON incorrect dans input à côté de la ligne 1 colonne 85959: Some code points did not transcode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here a sample from the code i'm using :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;This run in a macro wich loop calling the API a few times :

//Setting the filename to write down the JSON file&lt;BR /&gt;(not actual code; explaining the variables uses)
&amp;amp;api_call contains the url to the API
&amp;amp;fic_api_call contains the name of the file written
&amp;amp;boucle contains the loop number at that time being

FILENAME users "&amp;amp;api_call.&amp;amp;fic_api_call._&amp;amp;boucle..json";

//Calling the API and creating the users files&lt;BR /&gt;(same as above, not actual code)
&amp;amp;list contains a list of argument i'm giving the API

PROC HTTP
	METHOD="GET"
	CT="application/JSON"
	URL="&amp;amp;url.&amp;amp;list."
	OUT=users;
RUN;         

After the macro :
(not the same code as in my program but i'm setting the FILENAME this way)
FILENAME data "x:\api_call\file.json" ENCODING="UTF-8"
LIBNAME data JSON FILEREF=data&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've also read the opening sas 9.4 with unicode support work. Yes, it's working. But we're going to run this code/program on a SAS-SERVER wich is not set with the UFT-8 enconding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, need some help reading the JSON file &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 00:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725308#M225258</guid>
      <dc:creator>Pierre_L</dc:creator>
      <dc:date>2021-03-11T00:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Reading JSON file with JSON LIBNAME engine</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725321#M225269</link>
      <description>&lt;P&gt;Have you tried to set this encoding?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME users "&amp;amp;api_call.&amp;amp;fic_api_call._&amp;amp;boucle..json" ENCODING="UTF-8";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Mar 2021 01:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725321#M225269</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-03-11T01:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Reading JSON file with JSON LIBNAME engine</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725332#M225277</link>
      <description>&lt;P&gt;The error comes from the fact that some characters cannot be translated to you session's encoding.&lt;/P&gt;
&lt;P&gt;See here&amp;nbsp;&lt;A href="http://support.sas.com/kb/30/719.html" target="_blank"&gt;http://support.sas.com/kb/30/719.html&lt;/A&gt; for example.&lt;/P&gt;
&lt;P&gt;The only way according to this (old) support entry seems to be to remove the offending characters from the JSON file.&lt;/P&gt;
&lt;P&gt;Longer term, UTF8 is the new standard and you should probably move there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 02:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725332#M225277</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-03-11T02:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reading JSON file with JSON LIBNAME engine</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725423#M225328</link>
      <description>&lt;P&gt;Yes, i tried it and it didn't work!&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 13:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725423#M225328</guid>
      <dc:creator>Pierre_L</dc:creator>
      <dc:date>2021-03-11T13:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reading JSON file with JSON LIBNAME engine</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725428#M225333</link>
      <description>&lt;P&gt;You should insist that your local SAS administrator setup a method for you to run your code using UTF-8.&amp;nbsp; &amp;nbsp;It should not be very hard.&amp;nbsp; This is not the only problem you are going to have where you need to use UTF-8 encoded data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For now see what happens if you tell SAS to ignore the encoding? Or pretend that it is coded as whatever your current SAS session is using.&amp;nbsp; Hopefully that will allow the multiple byte UTF-8 characters to be copied as they are into your SAS datasets where you can then try to convert them to something more useful.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME data "x:\api_call\file.json" ENCODING="ANY" ;
LIBNAME data JSON FILEREF=data ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Mar 2021 13:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725428#M225333</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-11T13:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Reading JSON file with JSON LIBNAME engine</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725434#M225338</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I tried it and got the following error:&lt;/P&gt;&lt;P&gt;ERROR: JSON incorrect dans input à côté de la ligne 1 colonne 1: Encountered an illegal character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, we don't want the enconding to malfunction since the data is customer data we have to manipulate &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 13:43:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725434#M225338</guid>
      <dc:creator>Pierre_L</dc:creator>
      <dc:date>2021-03-11T13:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Reading JSON file with JSON LIBNAME engine</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725458#M225346</link>
      <description>&lt;P&gt;Another debugging step is to read the JSON file with a data step so you can read the text without transcoding.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  infile 'myfile.json'  encoding='any' truncover ;
  input line $char2000.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then try transcoding using SAS functions for transcoding strings and see if you can find the offending character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At which point you might be able to build logic to read the file and write an updated version that your SAS session can read.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 15:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725458#M225346</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-11T15:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reading JSON file with JSON LIBNAME engine</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725658#M225440</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;&amp;nbsp;we don't want the encoding to malfunction&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;You cannot read UTF-8 characters from a &lt;EM&gt;wlatin&lt;/EM&gt; sessions.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;wlatin&lt;/EM&gt; does know know anything about characters&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;อักษรไทย&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;or &lt;SPAN&gt;∀∁∂∃∄∅∆∇∈∉&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So either you lose "extended" characters or you read in an UTF-8 session.&lt;/SPAN&gt;&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>Thu, 11 Mar 2021 22:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-JSON-file-with-JSON-LIBNAME-engine/m-p/725658#M225440</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-03-11T22:24:46Z</dc:date>
    </item>
  </channel>
</rss>

