#1 2021-02-22 11:00:32

jaclas
Member
Registered: 2014-09-12
Posts: 215

JSON and objects

JSON and access by Variant (TDocVariant)

In the case of an array, we can use .Count() and .Values[] methods to get to individual items.

I have an JSON with object structure like this (but I don't have object declaration):

 
{
    "ONE": {
        "ABC": {
            "somethinA": {
                "value1": "30313233343536373839303132333435"
            },
            "SomethingB": {
                "value1": "303132333435363738393031323334353637383930313233"
            },
            "SomethingC": {
                "value4": "abcdefghijklmnopqrstuv0123456789"
            }
        },
        "DEF": {
            "SomethingD": {
                "value1": "3E94C6E319ABBB47403FACD6CA68A5AB36D32E6DDA6C58BF6A019F45E90DCCA0"
            },
            "SomethingE": {
                "value1": "303132333435363738393031323334353637383930313233"
            },
            "SomethingC": {
                "value1": "3CD2321C665DB1CA51014D65CC9D9AF46845010AD80018B1E256374558D79DB1"
            }
        },
        "GHI": {
             [...]
        }
     },
    "TWO": {
          [...]
       },
[...]

Is it possible to get what properties are available and iterate over them?

Last edited by jaclas (2021-02-22 11:17:58)

Offline

#2 2021-02-22 12:16:31

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: JSON and objects

Sure, you do it through the TDocVariantData structure. Check the doc examples https://synopse.info/files/html/Synopse … l#TITLE_39

Offline

Board footer

Powered by FluxBB