问题
I create JSON with abap methods.
For example:
DATA(lo_json_writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION id
SOURCE result = result
RESULT XML lo_json_writer.
cl_abap_conv_in_ce=>create( )->convert(
EXPORTING
input = lo_json_writer->get_output( )
IMPORTING
data = json ).
Which data type should I use for json?
Use string
or xstring
?
回答1:
There's no "good way". Each solution has advantages and drawbacks.
If your data contains mostly "latin" characters, then use xstring
with UTF-8 encoding, it will occupy less memory.
xstring
with UTF-8 encoding: one byte for common A-Z/a-z/0-9 characters, two bytes for accentuated characters, and more bytes for characters from other languages (Chinese and so on).string
: two bytes per character (encoding is likeUCS-2
), since all ABAP systems are now Unicode (ABAP >= 7.50).
回答2:
According to this blog-entry(https://blogs.sap.com/2013/01/07/abap-and-json/): "For storing XML data in strings or internal tables, we recommend that you use byte strings or byte-like line types" Therefore i would use xstring.
来源:https://stackoverflow.com/questions/55900518/what-type-to-use-for-json-string-or-xstring