Skip to content
CCPEDIAby Unity Nodes
App Development

DA.Set on JSON-API

5 posts601 views9 likesLast activity Feb 2024

  1. kctamOP 1

    Hi Team,

    I am seeing in some templates DA.Set is being used in “with” block. May I know what is the right way to incorporate this inside the payload in JSON-API (say in Postman using v1/create)? I have tried an empty [] but it doesn’t work.

    Thanks in advance.

    kc

  2. cocreature 6

    See REST JSON Specification - #2 by cocreature for the same question.

    As mentioned in there, the :json command in daml repl is very useful for finding the JSON encoding of a given value:

    daml> import qualified DA.Set as Set
    daml> :json Set.fromList [1,2,3]
    {"map":[[1,{}],[2,{}],[3,{}]]}
    
  3. kctam 1

    Hi @cocreature ,

    Thanks for your prompt response! It saves my day.

    cheers,
    kc

  4. Luciano

    We should add this to the doc here:

    https://docs.daml.com/json-api/lf-value-specification.html#genmap

  5. ivett 1

    To me a small code example would help, so adding one here. If you have a template like:

    template Foo
      with
        issuer : Party
        owners : Set.Set Party
    

    Then the JSON will be:

      "payload": {
        "issuer": "<party_name>::<hash>",
        "owners": {
          "map": [
            [
              "<party_name>::<hash>",
              {}
            ],
            [
             "<party_name>::<hash>",
              {}
            ]
          ]
        }
      }