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}}

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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