Set Default Value In Argument With Type List<Dictionary(string, object)>

i have argument with type List<Dictionary(string, object)>, how to default value with the real value, example i have data like this

[
  {
    "encoder": "Encoder1",
    "data": {
      "rtmps": [
        "rtmp://a.rtmp.youtube.com",
        "rtmp://a.rtmp.youtube.com",
        "rtmp://a.rtmp.youtube.com"
      ]
    }
  },
  {
    "encoder": "Encoder2",
    "data": {
      "rtmps": [
        "rtmp://a.rtmp.youtube.com",
        "rtmp://a.rtmp.youtube.com"
      ]
    }
  },
  {
    "encoder": "Encoder3",
    "data": {
      "rtmps": [
        "rtmp://a.rtmp.youtube.com"
      ]
    }
  }
]

how to set that value in default value that has type List<Dictionary(string, object)>

one of many options:

  • check if in Argument is empty / null
  • then construct the the default value and set it

Maybe a read-in / usage of a JSON string and deserializing it into the dictionary can simplify it

Somehow like this?

New List(Of Dictionary(Of String, Object)) From 
{ 
New Dictionary(Of String, Object) From {{"Encoder1", ""}},  
New Dictionary(Of String, Object) From {{"Encoder2", ""}}
}

Cheers

Hey @J0ska
Try below as example

if (argument == null || argument.Count == 0)
    {
        argument = new List<Dictionary<string, object>>
        {
            new Dictionary<string, object>
            {
                { "encoder", "Zero value in dictionary" },
                { "data", "Zero value in dictionary" }
            },
         }