1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-16 04:50:05 +00:00

fix: switching to data step for JSON generation in mp_jsonout and the sasjs/adapter for improved reliability when data contains special characters. Closes #12

This commit is contained in:
Allan Bowe
2021-04-07 22:28:42 +00:00
parent a7fdb52231
commit 456d10a90e
2 changed files with 17 additions and 12 deletions

View File

@@ -4,8 +4,11 @@
@details PROC JSON is faster but will produce errs like the ones below if @details PROC JSON is faster but will produce errs like the ones below if
special chars are encountered. special chars are encountered.
>An object or array close is not valid at this point in the JSON text. > ERROR: Some code points did not transcode.
>Date value out of range
> An object or array close is not valid at this point in the JSON text.
> Date value out of range
If this happens, try running with ENGINE=DATASTEP. If this happens, try running with ENGINE=DATASTEP.
@@ -14,7 +17,9 @@
filename tmp temp; filename tmp temp;
data class; set sashelp.class;run; data class; set sashelp.class;run;
%mp_jsonout(OPEN,jref=tmp)
%mp_jsonout(OBJ,class,jref=tmp) %mp_jsonout(OBJ,class,jref=tmp)
%mp_jsonout(CLOSE,jref=tmp)
data _null_; data _null_;
infile tmp; infile tmp;
@@ -27,18 +32,18 @@
For more information see https://sasjs.io For more information see https://sasjs.io
@param action Valid values: @param action Valid values:
* OPEN - opens the JSON @li OPEN - opens the JSON
* OBJ - sends a table with each row as an object @li OBJ - sends a table with each row as an object
* ARR - sends a table with each row in an array @li ARR - sends a table with each row in an array
* CLOSE - closes the JSON @li CLOSE - closes the JSON
@param ds the dataset to send. Must be a work table. @param ds the dataset to send. Must be a work table.
@param jref= the fileref to which to send the JSON @param jref= the fileref to which to send the JSON
@param dslabel= the name to give the table in the exported JSON @param dslabel= the name to give the table in the exported JSON
@param fmt= Whether to keep or strip formats from the table @param fmt= Whether to keep or strip formats from the table
@param engine= Which engine to use to send the JSON, options are: @param engine= Which engine to use to send the JSON, valid options are:
* PROCJSON (default) @li PROCJSON (default)
* DATASTEP @li DATASTEP (more reliable when data has non standard characters)
@param dbg= DEPRECATED - was used to conditionally add PRETTY to @param dbg= DEPRECATED - was used to conditionally add PRETTY to
proc json but this can cause line truncation in large files. proc json but this can cause line truncation in large files.

View File

@@ -1,5 +1,5 @@
/** /**
@file mv_webout.sas @file
@brief Send data to/from the SAS Viya Job Execution Service @brief Send data to/from the SAS Viya Job Execution Service
@details This macro should be added to the start of each Job Execution @details This macro should be added to the start of each Job Execution
Service, **immediately** followed by a call to: Service, **immediately** followed by a call to:
@@ -11,7 +11,7 @@
following syntax: following syntax:
data some datasets; * make some data ; data some datasets; * make some data ;
retain some columns; retain some columns;
run; run;
%mv_webout(OPEN) %mv_webout(OPEN)
@@ -162,7 +162,7 @@
%end; %end;
%else %if &action=ARR or &action=OBJ %then %do; %else %if &action=ARR or &action=OBJ %then %do;
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt
,jref=&fref,engine=PROCJSON,dbg=%str(&_debug) ,jref=&fref,engine=DATASTEP,dbg=%str(&_debug)
) )
%end; %end;
%else %if &action=CLOSE %then %do; %else %if &action=CLOSE %then %do;