JSON sample not working

General APL language issues

JSON sample not working

Postby neeraj on Fri Sep 25, 2015 7:30 pm

I started looking at the JSON I-beams and my very first sample did not work. Here it is

Code: Select all
{"first_name" : "Neeraj",
"last_name" : "Gupta",   
"stocks" :               

 j←0 (7159⌶) A

j.stocks.⎕nl 2 
 S1  S2

Posts: 82
Joined: Wed Dec 02, 2009 12:10 am
Location: Ithaca, NY, USA

Re: JSON sample not working

Postby Brian|Dyalog on Sat Sep 26, 2015 6:07 pm

Hi Neeraj,

Actually it is working properly.
j.stocks is a 2 item vector of JSON objects
#.[JSON object].[JSON object] #.[JSON object].[JSON object]

If you turn ]box on, you can see that j.stocks.⎕NL -2 is a 2 item vector of namelists.
      z.stocks.⎕NL -2

S1 is in the first item, and S2 is in the second.
j.stocks.S1 is referring to the S1 element in all items, and the VALUE ERROR occurs because there is no S1 element in the second item.
So, to reference S1 and S2 you need to select the appropriate item.
User avatar
Posts: 112
Joined: Thu Nov 26, 2009 4:02 pm
Location: West Henrietta, NY

Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest