我有一个想要反序列化的匿名数组,这里是第一个数组对象的示例
[
{ "time":"08:55:54",
"date":"2016-05-27",
"timestamp":1464332154807,
"level":3,
"message":"registerResourcePath ('', '/sap/bc/ui5_ui5/ui2/ushell/resources/')",
"details":"","component":"sap.ui.ModuleSystem"},
{"time":"08:55:54","date":"2016-05-27","timestamp":1464332154808,"level":3,"message":"URL prefixes set to:","details":"","component":"sap.ui.ModuleSystem"},
{"time":"08:55:54","date":"2016-05-27","timestamp":1464332154808,"level":3,"message":" (default) : /sap/bc/ui5_ui5/ui2/ushell/resources/","details":"","component":"sap.ui.ModuleSystem"}
]
我尝试使用反序列化CL_TREX_JSON_SERIALIZER
,但它已损坏并且不适用于我的 JSON,这就是为什么 https://stackoverflow.com/questions/16154293/how-to-encode-json-in-abap
然后我尝试了/UI2/CL_JSON
,但它需要一个完全适合 JSON 对象给出的对象的“结构”。 “结构”在我的例子中意味着具有属性的对象的内部表time, date, timestamp, level, message
anddetails
。存在问题:它不能正确处理引用并使用类描述来描述分配给字段符号的字段。由于我不能拥有对象列表,而只能拥有对对象的引用列表,因此该解决方案也不起作用。
作为第三次尝试,我尝试了CALL TRANSFORMATION
正如所描述的霍斯特·凯勒 https://scn.sap.com/community/abap/blog/2013/01/07/abap-and-json,但是用这种方法我无法读取匿名数组,这就是为什么 https://scn.sap.com/community/abap/blog/2013/04/15/abap-2-json-and-json-2-abap-with-st
我的主要观点:
- 我不想更改 JSON,因为这是我从中得到的
sap.ui.log
- 我更喜欢使用内置功能而不是第三方框架