SAP Data Services无法读取整个JSON格式

2020-08-14 19:49发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


你好! 我正在尝试使用extract_from_json函数提取JSON数据,但是无法正确读取JSON格式。 我有很多嵌套的JSON,以及具有相同名称但可能不同的嵌套元素的元素。

我尝试导入的JSON样本:

 {
     " storeNumber":" 429",
     " commandList":[{
             " command":" i10100",
             " messageDateTime":" 2003171346",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " alarmTypeCode":" 01",
                             " alarmWarningCode":" 01",
                             " tankSensorNum":" 01"
                         }
                     }
                 ]
             }
         },{
             " command":" i10200",
             " messageDateTime":" 2004091308",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " numToFollow":" 16"
                         },
                         " nestedCommandContentList":[{
                                 " nestedCommandContentMap":{
                                     " powerOnReset":" 162516.64",
                                     " slotNumber":" 1",
                                     " typeOfModule":" 10",
                                     " currentIoReading":" 162177.7"
                                 }
                             }
                         ]
                     }
                 ]
             }
         },{
             " command":" i11100",
             " messageDateTime":" 2004011344",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " alarmTypeCode":" 04",
                             " alarmState":" 01",
                             " alarmWarningCode":" 02",
                             " sensorCategory":" 00",
                             " alarmDate":" 2003242352",
                             " tankSensorNumber":" 03"
                         }
                     }
                 ]
             }
         },{
             " command":" i11200",
             " messageDateTime":" 2004021818",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " alarmTypeCode":" 07",
                             " alarmState":" 01",
                             " alarmWarningCode":" 02",
                             " sensorCategory":" 00",
                             " alarmDate":" 2003251953",
                             " tankSensorNumber":" 03"
                         }
                     },{
                         " contentMap":{
                             " alarmTypeCode":" 07",
                             " alarmState":" 02",
                             " alarmWarningCode":" 02",
                             " sensorCategory":" 00",
                             " alarmDate":" 2003242345",
                             " tankSensorNumber":" 03"
                         }
                     }
                 ]
             }
         },{
             " command":" i20100",
             " messageDateTime":" 2004091311",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " productCode":" 1",
                             " numToFollow":" 07",
                             " tankStatus":" 0000",
                             " tankNumber":" 01"
                         },
                         " nestedCommandContentList":[{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 8513.0"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 8588.0"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 3114.0"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 63.1825"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 0.0"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 47.236423"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 0.0"
                                 }
                             }
                         ]
                     }
                 ]
             }
         },{
             " command":" i20700",
             " messageDateTime":" 2004091310",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " numToFollow":" 0E",
                             " tankNumber":" 01"
                         },
                         " nestedCommandContentList":[{
                                 " nestedCommandContentMap":{
                                     " leakHistoryNumber":" 01",
                                     " leakTestDuration":" 0.0",
                                     " leakTestVolume":" 9402.489",
                                     " inTankLeakTestType":" 02",
                                     " leakReportType":" 00",
                                     " inTankLeakTestStartTime":" 2004090416",
                                     " leakTestPercentage":" 80.867714"
                                 }
                             }
                         ]
                     }
                 ]
             }
         },{
             " command":" i30100",
             " messageDateTime":" 2004091311",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " sensorStatus":" 0000",
                             " sensorNumber":" 01"
                         }
                     }
                 ]
             }
         },{
             " command":" i30200",
             " messageDateTime":" 2005081145",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " numToFollow":" 02",
                             " sensorNumber":" 01"
                         },
                         " nestedCommandContentList":[{
                                 " nestedCommandContentMap":{
                                     " alarmDateTime":" 2003192107",
                                     "警报类型描述":"未知警报类型",
                                     " alarmTypeNumber":" 0002"
                                 }
                             }
                         ]
                     }
                 ]
             }
         }
     ]
 }


 

我从该文件创建了一个JSON嵌套模式,但这是我得到的输出:

显然,结点数比引入的结点数更多,但是嵌套的内容可能有所不同。 我尝试手动添加到格式,但是当我保存它时,格式就静止了。 如何获得数据服务以正确读取此JSON?

(236.0 kB)

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


你好! 我正在尝试使用extract_from_json函数提取JSON数据,但是无法正确读取JSON格式。 我有很多嵌套的JSON,以及具有相同名称但可能不同的嵌套元素的元素。

我尝试导入的JSON样本:

 {
     " storeNumber":" 429",
     " commandList":[{
             " command":" i10100",
             " messageDateTime":" 2003171346",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " alarmTypeCode":" 01",
                             " alarmWarningCode":" 01",
                             " tankSensorNum":" 01"
                         }
                     }
                 ]
             }
         },{
             " command":" i10200",
             " messageDateTime":" 2004091308",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " numToFollow":" 16"
                         },
                         " nestedCommandContentList":[{
                                 " nestedCommandContentMap":{
                                     " powerOnReset":" 162516.64",
                                     " slotNumber":" 1",
                                     " typeOfModule":" 10",
                                     " currentIoReading":" 162177.7"
                                 }
                             }
                         ]
                     }
                 ]
             }
         },{
             " command":" i11100",
             " messageDateTime":" 2004011344",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " alarmTypeCode":" 04",
                             " alarmState":" 01",
                             " alarmWarningCode":" 02",
                             " sensorCategory":" 00",
                             " alarmDate":" 2003242352",
                             " tankSensorNumber":" 03"
                         }
                     }
                 ]
             }
         },{
             " command":" i11200",
             " messageDateTime":" 2004021818",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " alarmTypeCode":" 07",
                             " alarmState":" 01",
                             " alarmWarningCode":" 02",
                             " sensorCategory":" 00",
                             " alarmDate":" 2003251953",
                             " tankSensorNumber":" 03"
                         }
                     },{
                         " contentMap":{
                             " alarmTypeCode":" 07",
                             " alarmState":" 02",
                             " alarmWarningCode":" 02",
                             " sensorCategory":" 00",
                             " alarmDate":" 2003242345",
                             " tankSensorNumber":" 03"
                         }
                     }
                 ]
             }
         },{
             " command":" i20100",
             " messageDateTime":" 2004091311",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " productCode":" 1",
                             " numToFollow":" 07",
                             " tankStatus":" 0000",
                             " tankNumber":" 01"
                         },
                         " nestedCommandContentList":[{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 8513.0"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 8588.0"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 3114.0"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 63.1825"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 0.0"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 47.236423"
                                 }
                             },{
                                 " nestedCommandContentMap":{
                                     " ieeeFloat":" 0.0"
                                 }
                             }
                         ]
                     }
                 ]
             }
         },{
             " command":" i20700",
             " messageDateTime":" 2004091310",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " numToFollow":" 0E",
                             " tankNumber":" 01"
                         },
                         " nestedCommandContentList":[{
                                 " nestedCommandContentMap":{
                                     " leakHistoryNumber":" 01",
                                     " leakTestDuration":" 0.0",
                                     " leakTestVolume":" 9402.489",
                                     " inTankLeakTestType":" 02",
                                     " leakReportType":" 00",
                                     " inTankLeakTestStartTime":" 2004090416",
                                     " leakTestPercentage":" 80.867714"
                                 }
                             }
                         ]
                     }
                 ]
             }
         },{
             " command":" i30100",
             " messageDateTime":" 2004091311",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " sensorStatus":" 0000",
                             " sensorNumber":" 01"
                         }
                     }
                 ]
             }
         },{
             " command":" i30200",
             " messageDateTime":" 2005081145",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " numToFollow":" 02",
                             " sensorNumber":" 01"
                         },
                         " nestedCommandContentList":[{
                                 " nestedCommandContentMap":{
                                     " alarmDateTime":" 2003192107",
                                     "警报类型描述":"未知警报类型",
                                     " alarmTypeNumber":" 0002"
                                 }
                             }
                         ]
                     }
                 ]
             }
         }
     ]
 }


 

我从该文件创建了一个JSON嵌套模式,但这是我得到的输出:

显然,结点数比引入的结点数更多,但是嵌套的内容可能有所不同。 我尝试手动添加到格式,但是当我保存它时,格式就静止了。 如何获得数据服务以正确读取此JSON?

(236.0 kB)
付费偷看设置
发送
1条回答
浮生未央
1楼-- · 2020-08-14 20:33

嘿,

请查看以下注释:

https://launchpad.support.sap.com/#/notes/0002713764

将JSON文件导入Designer时,文件中的第一条记录用于定义架构。 就您而言,仅采取以下措施:

" storeNumber":" 429",
     " commandList":[{
             " command":" i10100",
             " messageDateTime":" 2003171346",
             " commandValues":{
                 " commandContentList":[{
                         " contentMap":{
                             " alarmTypeCode":" 01",
                             " alarmWarningCode":" 01",
                             " tankSensorNum":" 01"
                         }
                     }
                 ]
             }
         }
 

确保您构建的示例将完整的可能结构表示为输入文件,或使用相应的JSON模式导入到DS中,即使用 https://jsonschema.net/home

否则,您确实可以直接在DS中手动构建结构-但是-不要忘记偶尔将手动更改的结构保存在DS中。

此致

朱利安

一周热门 更多>