How do I fix these parameters for HTTPBODY in swift?

Bob

I have;

let parameters =
        [
          "generalSearchInput": search,
          "requireAllWords": true,
          "brandOwner": brand,
          "includeDataTypes":
          {
              "Branded": true
          }
        ] as [String : Any]

THE ABOVE OBVIOUSLY DOES NOT WORK, I just do not understand how to do nested.

I am trying to mimic;

{
    "generalSearchInput": "SHARP CHEDDAR CHEESE",
    "requireAllWords": true,
    "brandOwner": "usa",
    "includeDataTypes": 
    {
        "Branded": true
    }
}

Thanks

Sh_Khan

Try

let parameters: [String : Any] =
    [
      "generalSearchInput": search,
      "requireAllWords": true,
      "brandOwner": brand,
      "includeDataTypes":
      [
          "Branded": true
      ]
    ]  

In swift dictionary composing a json dictionary is expressed with [:] and array with [ ]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related