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 .
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.
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.