Alamofire: Sending JSON as request parameter

后端 未结 1 1583
孤城傲影
孤城傲影 2020-12-07 06:56

I have an incredibly long array and string I want to send through Alamofire though I don\'t know how I would send raw JSON as a parameter. The JSON looks a little like

相关标签:
1条回答
  • 2020-12-07 07:07

    I don't know Alamofire, but I just googled for it and found something in its ReadMe on GitHub....

    let parameters = [
        "foo": "bar",
        "baz": ["a", 1],
        "qux": [
            "x": 1,
            "y": 2,
            "z": 3
        ]
    ]
    
    Alamofire.request(.POST, "http://httpbin.org/post", parameters: parameters)
    // HTTP body: foo=bar&baz[]=a&baz[]=1&qux[x]=1&qux[y]=2&qux[z]=3
    

    https://github.com/Alamofire/Alamofire

    Here you have an Dictionary (Dictionary is like a JSON) and also a parameter with another Dictionary(JSON) as value of a parameter...

    Is that what you need?

    0 讨论(0)
提交回复
热议问题