Convert a text in a Dictionary List

Hi,
I'm creating an interface where I load a local variable. This local variable is a cdt, so I use the function cast to convert it. I need to populate a field of this variable, so I build the following string:
{{Id:1},{Id:2},{Id:3}}.
Now I need to convert it in a dictionary, but it always return me an empty value.
I would like to know if you have some idea about it.
Thanks in advance.

OriginalPostID-250259

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Generally, if the Data: {{Id:1},{Id:2},{Id:3}} is of type String and you want to convert it into Dictionary or DataSubset format, then you could do something as below:-


    For Dictionary:
    ====================================
    load(
    local!data: "{{Id:1},{Id:2},{Id:3}}",
    local!a: a!toJson(todatasubset(local!data)),
    local!b: a!fromJson(local!a),
    local!b
    )
    =====================================


    For Datasubset
    ====================================
    load(
    local!data: "{{Id:1},{Id:2},{Id:3}}",
    todatasubset(local!data)
    )

    ==================================

    Hope this will help you
Reply
  • 0
    Certified Lead Developer
    Generally, if the Data: {{Id:1},{Id:2},{Id:3}} is of type String and you want to convert it into Dictionary or DataSubset format, then you could do something as below:-


    For Dictionary:
    ====================================
    load(
    local!data: "{{Id:1},{Id:2},{Id:3}}",
    local!a: a!toJson(todatasubset(local!data)),
    local!b: a!fromJson(local!a),
    local!b
    )
    =====================================


    For Datasubset
    ====================================
    load(
    local!data: "{{Id:1},{Id:2},{Id:3}}",
    todatasubset(local!data)
    )

    ==================================

    Hope this will help you
Children
No Data