Question
· Sep 22, 2024

Property of list of lists

Hello, i need to make property that is of type List of Lists of String (see "body_text" in JSON)

How can i make it? 

Thanks

{
  "type": "BODY",
  "text": "<TEXT>",
  
  # Required if <TEXT> string contains variables
  "example": {
    "body_text": [
      [
        <BODY_TEXT>
      ]
    ]
  }
}
Product version: IRIS 2022.1
$ZV: IRIS for Windows (x86-64) 2022.1.1 (Build 374U)
Discussion (1)1
Log in or sign up to continue

In case, you talk about Cache/IRIS-Classes:

Class Example.Test Extends %Persistent
{
Property BodyText As list Of MyList;
}


Class Example.MyList Extends %SerialObject
{
Property Text As list Of %String;
}

The steps to add data:

set test=##class(Example.Test).%New()

set list1=##class(Example.MyList).%New()
do list1.Text.Insert("red")
do list1.Text.Insert("green")
do list1.Text.Insert("blue")
do test.BodyText.Insert(list1)

set list2=##class(Example.MyList).%New()
do list2.Text.Insert("Joe")
do list2.Text.Insert("Paul")
do list2.Text.Insert("Bob")
do test.BodyText.Insert(list2)

write test.%Save() --> 1

zw ^Example.TestD
^Example.TestD=1
^Example.TestD(1)=$lb("",$lb($lb($lb($lb("red","green","blue"))),$lb($lb($lb("Joe","Paul","Bob")))))


zso test
BodyText(1).Text(1).: red
BodyText(1).Text(2).: green
BodyText(1).Text(3).: blue
BodyText(2).Text(1).: Joe
BodyText(2).Text(2).: Paul
BodyText(2).Text(3).: Bob