Trouble reading JSON output in SAS -


I am trying to parse the data from a JSON file in the SAS but stuck in my code. I can not post all JSON content because it is too long, but I can post part of what is relevant below is my SAS code; When I run it, I get something in the log that says "lost card" and I'm not sure what it means.

Part of the code is commented because the code actually works until I go ahead on my variable list ... I wonder ... does this error ("omitted card" ) Have something to do with the "LLCL" line and the length of some variables?

SAS code:

  file name OTP1 '... ... output  

otp1.json'; Data work.otp1sas; Infile OTP1LERLL = 32000 / * Trunkworker * / Scanover; Input @ 'Starttaim ":" Starttaim $ 20 @' Andtaim ":" Andtaim $ 20 @ 'Volktaim ":" Volktaim $ 20 @' Tronsmittaim ":" Tronsmittaim $ 20 / * @ 'Prticshaing time' Waiting time $ 20 @ "Walk Distance": 'Walking $ 20 Damage @' 'Volume Liquid Acc'ded': 'Walk Liked $ 20 Forward @' "Transfers": '$ 20 Transfers. * /; StartTime = Scan (starttime, 1, ',' '); Endtime = scan (end time, 1, ',' '); WalkTime = Scan (Warning, 1, ',' '); Transmittime = scan (transit time, 1, ',' '); / * Waiting = scan (waiting time, 1, ',' '); Walk Dysense = Scan (Walk, 1, ',' '); WalkLimitExceeded = Scan (VolleyMilit Acceded, 1, ',' '); Transfer = scan (transfer, 1, ',' '); * / Run; JSON content (which is relevant to the above code):

  {"Request parameter": {"Date": "03-14-2014", "Mode": "Transit, Walk" , "ComeBy": "false", "showIntermediateStops": "false", "fromPlace": "33.8134605, -84.3,4 9, 73,148", "itinIndex": "0", "toPlace": "33.80882004 "": "Time": "10:00 am", "maxWalkDistance": "3218.688"}, "Plan": {"Date": 1394805600000, "to": {"Name": "Arlington Avenue North East "" StopId ": null," StopCode ": null," PlatformCode ": null," longitude ": - 84.34880165944314," lat ": 33.81255118156955," Arrival ": null," which ": null," original ": null , "Zonai "", "Stop": blank, "platform": blank, "loan" Null, "stopIndex": null), "routes": [{"period": "84", "lat": 33.808417712941896, "arrival": null, "departure": null, "root": null, "zoneId" : 2630.0, "STARTTIME": 1394806613000, "eNDTIME": 1394809243000, "walkTime": 994, "transitTime": 1273, "waitingTime": 363, "walkDistance": 1280.0733818655874, "walkLimitExceeded": false, "eleva TionLost": 0.0, "height gain": 0.0, "transfer": 2, "   

< P> If you are not close enough with SAS 9.3+, you can use the following
  filename otp1 '... \ output \ otp1.json'; Data work.otp1sas; Format equation $ 60 Convertible $ 32 Price $ 32 Beginner time $ 20 End time $ 20 Walk timeTime $ 20 Transmit time $ 20 Waiting time $ 20 Moving $ 20 WalkLimit $ 20 Moving $ 20 Transfer; ** Read JSON and separate relevant objects ** **; Infile OTP1LRCL = 32000 Trunkworker; Input @ "Travel Program": ['JasonRay $ 32000 ;; JsonArray = Scan (jsonArray, 1,'] '); ** Separate objects ** **; do objNr = 1 to countw (jsonArray,'} { 'JsonObject = Bar (Scan (jsonArray, objNr,'} {')); ** Equate the equations ** ** ** Count the VarNr = 1 (jsonObject,', '); equation = bar (Scan (JsonObject, varNr, ',')) variable = scan (equation, 1, '' '); value = substrate (equation, index (equation,': ') + 1); ** handle such cases where String value includes commas; ** While (varNr LT Countw (jsonObject, ',') and substr (value, 1, 1) EQ '' 'and substr ( (Length), length (value), 1) NE '' '; varNr = varNr + 1; value = trim (value;' ',' || band (scan (jsonObject, varNr, ',')); end; selection Get (variable); while ( 'Starttaim') StartTime = Dequote (value); when ( 'Andtaim') Andtaim = when ( 'Voktaim') Walktime = Dequote (value); when ( 'Tronjittaim') Tronsmittaim = Dekwat (value When 'Waiting' is waitingTime = dequote (value); When ('Walk Distance') when 'Transfer (Transfer)' transfer = Decotet (Value); otherwise put varNr = variable = value =; End; End; If countw (jsonObject); If ('walkLimitExceeded') walkLimitExceeded = dequote (value); , ',') GT then output; End; Run;    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -