BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DBailey
Lapis Lazuli | Level 10

I'm trying to import the FEMA disaster areas using their JSON api.  Proc HTTP completes with status code 200 (normal) but the libname statement returns an error that i can't trace.  Column 567 is in the middle of the first record and doesn't appear to have invalid characters.  Any ideas on where to look?

 

ERROR: Invalid JSON in input near line 1 column 567: Unexpected characters found after valid JSON text.
ERROR: Error in the LIBNAME statement.

 

filename resp temp;
proc http 
	url = "https://www.fema.gov/api/open/v1/DisasterDeclarationsSummaries.json" 
	method = "get" 
	out = resp; 
run;
libname res json fileref=resp;
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

I had a look.

This file is a suite of { } groups, with no overall structure. It's invalid jason.

 

You need to add an overall structure to go from

{"disasterNumber":1}{"disasterNumber":3}

to something like:

{"event1":{"disasterNumber":1},"event2":{"disasterNumber":3}}

View solution in original post

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

What does this generate?

data _null_;

  infile RESP lrecl=600;

  input;

  A= rank(char(_infile_,567)) ;

  putlog '~' _N_ '~' A '~' ;

  if _N_=10 then stop;

run;

 

DBailey
Lapis Lazuli | Level 10

~1 ~123 ~

ChrisNZ
Tourmaline | Level 20

123 is the opening curly bracket {.

So that's a valid character.

The issue must therefore be the structure of the JSON file.

Save the file as a text file and look at how it is broken when opening a new { } block at that position.

 

I've changed to thread tile to  json library unexpected character from  json library invalid character

ChrisNZ
Tourmaline | Level 20

I had a look.

This file is a suite of { } groups, with no overall structure. It's invalid jason.

 

You need to add an overall structure to go from

{"disasterNumber":1}{"disasterNumber":3}

to something like:

{"event1":{"disasterNumber":1},"event2":{"disasterNumber":3}}

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3433 views
  • 0 likes
  • 2 in conversation