If I want to develop a serializer for a language for which one doesnt exist already (e.g. ABAP), what could be the efforts involved in it? Does it involve merely writing "text equivalent" of ABAP serialzer - how would I tackle complex objects. What would be the best starting point for this?
相关问题
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Design RESTful service with multiple ids
- Axios OPTIONS instead of POST Request. Express Res
相关文章
- json_encode 没有把数组转为json
- Livy Server: return a dataframe as JSON?
- Using JAX-WS 2.2.5 client with JDK/JRE 1.5
- Unexpected end of JSON input from an ajax call
- How do I do a nested list (array) of schema refere
- iconv() Vs. utf8_encode()
- Convert C# Object to Json Object
- LINQ .Include() properties from sub-types in TPH i
Update: Starting with Releases 7.02 and 7.03/7.31 (kernel patch 116), JSON is supported natively in ABAP - check this blog by Horst Keller.
You should search for ABAP and JSON using site:sap.com first and then choose one of the existing projects to learn from and contribute. However, if you're still out for the NIH bonus points, make sure you know how to use generic types, field symbols, RTTI and recursion inside out, then practice walking complex data structure recursively using RTTI. Once you've done that, assembling any kind of output string is easy.
There is a class that does exactly that : CL_TREX_JSON_SERIALIZER. The only thing it does not ( and SAP told me thru customer message that they will not fix it, they don't support this code ) is put the attribute in double quotes.
This is easily fixed by adding on line 52 in CL_TREX_JSON_SERIALIZER-RECURSE:
An example program would be:
I use zcl_trex_json_serializer which is a clone of cl_trex_json_serializer with the beforementioned fix. This code will return :
{"type": "E", "code": "BC", "message": "This will serialize correctly.", "log_no": "", "log_msg_no": "000000", "message_v1": "", "message_v2": "", "message_v3": "", "message_v4": ""}
I have used this code on structures that contain tables etcetera; the code seems to be able to handle it all.
In addition to vwegert's response check out SAP to Json transforms