如何在 Uniface 中为 json 创建一个结构列表

How to create a list with struct for a json in Uniface

我需要用编程语言 uniface 创建一个 json。我使用一个结构来创建 json。但是我在创建带有结构的列表时遇到了问题。

在此处查看我的“儿童”列表示例。

示例 - JSON:

{
    "First Name" : "Barbara",
    "Last Name" :  "Singh",
    "Date of birth" :   { "year" : 1955, "month" : 1, "day" : 23 }, 
    "Married" : true,
    "Children" :  
    [
        {  "Name" : "Martin", "Year of birth" :  1980 },
        {  "Name" : "Margaret", "Year of birth" : 1983 }        
    ],
    "Mobile phone" : null
} 

示例 - 结构:

[]
    [First Name] = "Barbara"
    [Last Name]  = "Singh"
    [Date of birth]
        [year] = 1732             
        [month] = 2               
        [day] = 22                
    [Married] = "T"               
    [Children]
        []
             [Name] = "Martin"
             [Year of birth] = 1980      
        []
             [Name] = "Margaret"   
             [Year of birth] = 1983      
     [Mobile phone] 

基于 Uniface 文档的示例:Structs for JSON Data

那么,我如何为 json 创建一个单面列表?

我找到了一个基于 post "How to create a list with struct for a json in Uniface 的解决方案,它启发了我的解决方案。

解决方案:

myStructure = $newstruct
myStructure->Children = $newstruct
myStructure->Children->$tags->jsonClass="array"

forlist sRecordPerson, nCounter in sListOfPersons
  sStruktur->Children-><NULL>{nCounter} = $newstruct

  sStruktur->Children-><NULL>{nCounter}->Name = $item("Name", sRecordPerson)
  sStruktur->Children-><NULL>{nCounter}->Yearofbirth = $item("Yearofbirth", sRecordPerson)

endfor