【发布时间】:2019-06-04 15:01:10
【问题描述】:
我在弄清楚如何从 Apache olingo 构建的 uri 中提取数据时遇到问题。从 $expand 中提取数据使用这种语法。
uri: odata/PropertyOrigin?$expand=Property1($select=Field1);$expand=Property2($select=Field1ofProperty2))
/* JSON ->
PropertyOrigin ->
Field1Origin,
Field2Origin,
NavigationProperty1 ->
Field1,
Field2,
Field3,
NavigationProperty2 ->
NavigationField1ofProperty2 <- the one I am trying to extract */
ClientEntity ce = csi.next();
String ExtractData1 = ce.getProperty("Property1").getComplexValue().get("Field1").getValue().toString();
但是,当我尝试从第二个 $expand 获取数据时,我得到了一个对象空引用,因为它没有触及我尝试与之交互的正确属性。
ClientEntity ce = csi.next();
String ExtractData2 = ce.getProperty("NavigationProperty1").getComplexValue().get("NavigationProperty2").getComplexValue().get("Field1ofNavigationProperty2").getValue().toString();
注意: NavigationProperty2 是一个集合
【问题讨论】:
标签: java apache nested odata olingo