Published on InterSystems Developer Community (https://community.intersystems.com)

Home > JSONStream to Object - Array of Array

Question
Claude Mourzelas · 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 

#JSON #ObjectScript #InterSystems IRIS for Health
Product version: IRIS 2022.2
$ZV: RIS for Windows (x86-64) 2022.2 (Build 304U) Sun Jul 31 2022 23:55:27 EDT

Source URL:https://community.intersystems.com/post/jsonstream-object-array-array