Question
· Feb 28, 2023

JSONStream to Object - Array of Array

Hello,

I'm trying to populate an object with method :  JSONStreamToObject

This is an extract from my JSON:

 "GEOMETRIE_POINT": {
    "GEO_TAB_COORDONNES": [
      673993.9987,
      7048087.2013
    ]
  },
  "GEOMETRIE_LINE": {
    "GEO_TAB_COORDONNES": [
      [
        675221.6371,
        7049913.2718
      ],
      [
        675149.6053,
        7049998.3874
      ]
    ]
  }

It work fine with GEOMETRIE_POINT with this class definition:

Class Test.GEOMETRIEPOINT Extends (%Persistent, %JSON.Adaptor, %XML.Adaptor, %RegisteredObject, Ens.Request) [ Inheritance = right, ProcedureBlock ]
{

Property "GEO_TAB_COORDONNES" As list Of %Float;
}

But impossible to find the good definition for GEOMETRIE_LINE ! This definition doesn't work (=> %ObjectErrors)

Class Test.GEOMETRIELINE Extends (%Persistent, %JSON.Adaptor, %XML.Adaptor, %RegisteredObject, Ens.Request) 
{

Property "GEO_TAB_COORDONNES" As %ArrayOfObjects;
}


 

Il you have a solution too for this JSON ?

  "GEOMETRIE_POLYGON": {
    "GEO_TAB_COORDONNES": [
      [
        [
          [
            675221.6371,
            7049913.2718
          ],
          [
            675149.6053,
            7049998.3874
          ]
        ]
      ]
    ]

Thanks 

Product version: IRIS 2022.2
$ZV: RIS for Windows (x86-64) 2022.2 (Build 304U) Sun Jul 31 2022 23:55:27 EDT
Discussion (4)2
Log in or sign up to continue

According to your JSON model, I would assume this to start:
(sory had no chance to test myself)

Class Test.GEOMETRIEPOINT Extends (%SerialObject, %JSON.Adaptor, %XML.Adaptor) 
{

Property "GEO_TAB_COORDONNES" As list Of %Float;
}

Class Test.GEOMETRIELINE Extends (%SerialObject, %JSON.Adaptor, %XML.Adaptor)
{

Property "GEOMETRIE_LINE" As list Of GEOMETRIEPOINT;
}

Class Test.POLYGON Extends (%Persistent,%JSON.Adaptor, %XML.Adaptor)
{

Property "GEOMETRIE_POLYGON" As list Of GEOMETRIELINE;
{

Hi Enrico,

For example:

{
  "count": 1,
  "success": true,
  "message": null,
      "GEOMETRIE_POLYGON": {
        "GEO_TAB_COORDONNES": [
          [
            [
              [
                674098.0036,
                7048055.5864
              ],
              [
                674101.3851,
                7048049.5203
              ],
              [
                674119.26,
                7048061.81
              ],
              [
                674129.4922,
                7048047.0958
              ]
            ]
          ]
         ]
      }
}