CURL转义单引号

CURL转义单引号,第1张

CURL转义单引号

我有同样的问题。最简单的解决方案是,除了用单引号引起来的撇号外,还要使用反斜杠来将其引起来。

'''

对于您的用例,更改

Mary's
Mary'''s
,它应该可以工作。

curl -XPOST 'http://localhost:9290/location/place' -d '{"geoloc": {"lat": "38.1899", "lon": "-76.5087"}, "longitude": "-76.5087", "admin_name1": "Maryland", "admin_name2": "St. Mary'''s", "admin_name3": "", "postal_pre": "20692", "admin_pre3": "", "country_pre": "US", "admin_pre1": "MD", "latitude": "38.1899", "admin_pre2": "037", "accuracy": null, "place_name": "Valley Lee"}'

另一种方法是将POST数据(

-d
)用双引号引起来,同时用反斜杠转义JSON字符串中所有嵌套的双引号。

curl -XPOST 'http://localhost:9290/location/place' -d "{"geoloc": {"lat": "38.1899", "lon": "-76.5087"}, "longitude": "-76.5087", "admin_name1": "Maryland", "admin_name2": "St. Mary's", "admin_name3": "", "postal_pre": "20692", "admin_pre3": "", "country_pre": "US", "admin_pre1": "MD", "latitude": "38.1899", "admin_pre2": "037", "accuracy": null, "place_name": "Valley Lee"}"


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4977488.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存