Chris Liu
Chris Liu

Reputation: 79

How to pass a json dictionary as part of url?

I want to deeplink a url into my ios app and i want to pass a dictionary like

[{"id": "fef", "hp": 1000},{"id": "afe"}]

I have tried

appname://command?p1=2&p2=[{"id": "fef", "hp": 1000},{"id": "afe"}]

in my iphone's safari but it treated this as i was googling it. do i have to escape something for the dictionary?

Upvotes: 1

Views: 1839

Answers (1)

Simon Marquis
Simon Marquis

Reputation: 7516

You must urlencode your json payload:

appname://command?p1=2&p2=%5B%7B%22id%22%3A%20%22fef%22%2C%20%22hp%22%3A%201000%7D%2C%7B%22id%22%3A%20%22afe%22%7D%5D

instead of

appname://command?p1=2&p2=[{"id": "fef", "hp": 1000},{"id": "afe"}]

Online url encoder: http://www.urlencoder.org/

Upvotes: 2

Related Questions