- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have JSON where the values have a forward slash in them such as "Amt w/total
"
{
"data" : [
{ "a" : 1 , "Amt w/total" : 10 },
]
}
So when the map is created it looks like
{
"NAME": "Amt_w_total",
"TYPE": "NUMERIC",
"PATH": "/root/data/Amt w/total"
}
This reads in as all missing because I assume it's treating the / as a separator in the path and looking for values of "Amt w
" and "total
".
Is there any way to tell it the slash is part of the value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Just a long shot:
Maybe SAS expects the / to be escaped, as in
Amt w\/total
and gets confused?
Does the map work if you correct the map?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ask SAS support for help.
It is definitely valid to have / in key value.
You can try it yourself:
https://www.w3schools.com/js/tryit.asp?filename=tryjson_object_loop
Not sure where to look for what is valid in that path syntax that the map files are using.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you cannot get it to work then perhaps your can made a modified version of the data that changes that value. Perhaps using unix tool like sed or even just reading the file in a datastep and using TRANWRD().
filename json temp;
options parmcards=json;
parcards4;
{
"data" : [
{ "a" : 1 , "Amt w/total" : 10 }
]
}
;;;;
filename fixed temp;
data _null_;
infile json;
file fixed;
input;
_infile_=tranwrd(_infile_,'"Amt w/total"','"Amt w_total"');
run;
filename map temp;
libname json json map=map automap=reuse;
proc print data=json.data;
run;
ordinal_ ordinal_ Amt_w_ Obs root data a total 1 1 1 1 10