1

I am making a post request with following params in HTTPBody:

filter:{“name”:"john”,”city”:”NY"}

I googled it but couldn't find the syntax

let params : [Dictionary<String,Dictionary<String,String>>] 
= [
            [
                "filter" : [
                    "name":"john",
                    "city":"NY"
                ]
            ]
        ]
  requestURL.HTTPBody = try NSJSONSerialization.dataWithJSONObject(params, options: [])

Could you please help me setting the above params in Swift code? Is there any syntax to put those params in HTTPBody?

Danboz
  • 561
  • 1
  • 5
  • 14

1 Answers1

1

This would be the correct syntax :

var params: Dictionary<String, Dictionary<String, String>> = [
    "filter" : [
        "name" : "john",
        "city" : "NY"          
    ]
]
ShahiM
  • 3,179
  • 1
  • 33
  • 58
  • It is not working! Do you know any other syntax to put this params in filter:{“name”:"john”,”city”:”NY"} – Danboz Dec 04 '15 at 00:51