Uploaded image for project: 'CloverDX'
  1. CloverDX
  2. CLO-18042

JSON parsing and serialization functions

    XMLWordPrintable

    Details

      Description

      Introduce two new functions:

      • function variant json2variant(<json_string>) - parses the specified JSON string and creates CTL “representation” of it - i.e. potentially complex structure of maps&lists&primitive types.
        variant myvariant;
        myvariant=json2obj('\{"city":"chicago","name":"jon doe","age":"22"}’);
        printErr(myvariant);
        

        Produces following output:

        {city=chicago, name=jon doe, age=22}
        

        JSON boolean is parsed to boolean, numbers to long (if integer) or decimal (if decimal part present).

      • function string variant2json(<variant var>|list|map) - serializes passed parameter into JSON style string.
        variant any;
        any={};
        any["A"]=[1,2,3];
        any["B"]=[true, false];
        any["C"]=\{"name"->"John", "surname"->"Doe"};
        printErr(obj2json(any));
        

        Produces:

        {"A":[1,2,3],"B":[true,false],"C":{"surname":"Doe","name":"John"}}
        

        Attachments

          Activity

            People

            Assignee:
            slamam Martin Slama
            Reporter:
            krivanekm Milan Krivanek
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h