BookmarkSubscribeRSS Feed
harigottala0
Fluorite | Level 6

Dear All,

we are fetching the data though the API. We are passing parameters in the below structure and response is getting in Json format.
But the problem is it storing in a string format by including extra double quote ("). duo to this we are not able to do the mapping.
we tried to remove the quote(") manually to verify is the required output getting. but it is throwing the error. But can able to do using java
scrpit .

2 REPLIES 2
ChrisHemedinger
Community Manager

Hi @harigottala0 ,

 

Are you saying that the JSON you get back from the API isn't actually valid JSON? You can test quickly by putting in the log:

 

data _null_;
 rc=jsonpp('resp','log');
run;

Or paste the JSON into one of the many free "JSON pretty print" sites around the internet. This will help validate the JSON.

 

If it's not valid JSON, then ideally the best course is to try and configure the service to provide valid JSON -- otherwise it's not much use as a RESTful service. But if that's not possible, maybe there is a way to post-process the JSON in SAS to fix it. We would need to see an example of the JSON response to advise on that.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
ChrisHemedinger
Community Manager

Or actually maybe you need a better way to form your input JSON. Try this.

 

filename input temp;
data _null_;
   file input;
   infile datalines;
   input;
   put _infile_;
datalines;
{
  "xxxxx": {
    "Mode": "x",   
    "Service_Name": "xxxxx",
    "P1": "",
    "P2": "",
    "P3": "",
    "P4": "",
    "5": ""
  }
}
;
run;

data _null_;
 rc=jsonpp('input','log');
run;
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1106 views
  • 0 likes
  • 2 in conversation