json中的网址包含反斜杠 [英] The url in json contains backslashes

查看:580
本文介绍了json中的网址包含反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道为什么我的wcf rest返回url中包含backslahses的json.如下:

I was just wondering why my wcf rest returns json which contains backslahses in the url. it is as below:

https:\/\/s3.amazonaws.com\/reiaustralia\/1fc00dfab25044ecb31e4882121b535e\/jpg\/download.jpg?AWSAccessKeyId=AKIAISTDESL6TBRAVM4Q&Expires=1380692091&Signature=MduuaUAjQRisadtM%2FDuVDemexLY%3D

谢谢

推荐答案

正斜杠可以在JSON中使用反斜杠进行转义,但不是必须的.因此,请选择以下任意一项:

Forward slashes can be escaped with a backslash in JSON, but they don't have to be. So either one of the following:

{"url":"http://www.example.com/"}
or
{"url":"http\/\/www.example.com\/"}

将解析为具有url属性且字符串值为http://www.example.com/的对象.

Will parse into an object which has a url property whose string value is http://www.example.com/.

有些技术在生成JSON时会逃脱斜线,而有些则不会.例如,PHP有一个名为 JSON_UNESCAPED_SLASHES 的选项,该选项可让您控制是否逃脱你的斜线.

Some technologies will escape out the slashes when generating JSON, and some won't. PHP, for example, has an option called JSON_UNESCAPED_SLASHES which lets you control whether or not to escape your slashes.

您可以在字符串"部分的 json.org 主页中看到各种转义字符.

You can get see the various escape characters from the json.org home page in the "string" section.

这篇关于json中的网址包含反斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆