我有同样的问题。最简单的解决方案是,除了用单引号引起来的撇号外,还要使用反斜杠来将其引起来。
'''
对于您的用例,更改
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"}"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)