Skip to main content

Hello everybody,

i need to create a json with the programming language uniface. I use a struct to create the json. But i have a problem to create a list with a struct.

See here my example for the list "Children".

Example - 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
} 

Example - Struct:

[]
    [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] 

Example based on the Uniface documentation: Structs for JSON Data

So, how can i create a list with uniface for a json?



------------------------------
Viktor Kuenstler
Abrechnungszentrum Emmendingen
------------------------------

Hello everybody,

i need to create a json with the programming language uniface. I use a struct to create the json. But i have a problem to create a list with a struct.

See here my example for the list "Children".

Example - 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
} 

Example - Struct:

[]
    [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] 

Example based on the Uniface documentation: Structs for JSON Data

So, how can i create a list with uniface for a json?



------------------------------
Viktor Kuenstler
Abrechnungszentrum Emmendingen
------------------------------
Hello Viktor,

You must define children as array  :  struct->Children->$tags->jsonClass="array"

Gilles.

------------------------------
Hortion Gilles
Agfa-Gevaert NV
------------------------------
Hello Viktor,

You must define children as array  :  struct->Children->$tags->jsonClass="array"

Gilles.

------------------------------
Hortion Gilles
Agfa-Gevaert NV
------------------------------
Thank you Gilles, it's works :)

------------------------------
Viktor Kuenstler
ARZ Haan AG
------------------------------

Hello everybody,

i need to create a json with the programming language uniface. I use a struct to create the json. But i have a problem to create a list with a struct.

See here my example for the list "Children".

Example - 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
} 

Example - Struct:

[]
    [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] 

Example based on the Uniface documentation: Structs for JSON Data

So, how can i create a list with uniface for a json?



------------------------------
Viktor Kuenstler
Abrechnungszentrum Emmendingen
------------------------------
Hi Viktor,

if you know the result (your JSON) do the reverse way.

jsontostruct V_STRUCT, V_JSON
putmess V_STRUCT->$dbgString

Now you can compare your struct with the result created by uniface.


Regards
Norbert

------------------------------
Norbert Lauterbach
Infraserv Gmbh & Co. Höchst Kg
Frankfurt DE
------------------------------
Hi Viktor,

if you know the result (your JSON) do the reverse way.

jsontostruct V_STRUCT, V_JSON
putmess V_STRUCT->$dbgString

Now you can compare your struct with the result created by uniface.


Regards
Norbert

------------------------------
Norbert Lauterbach
Infraserv Gmbh & Co. Höchst Kg
Frankfurt DE
------------------------------
Hi Norbert,

thanks for your advice. This could help me with other json problems.

------------------------------
Viktor Kuenstler
ARZ Haan AG
------------------------------