本文介绍了WCF可以接受使用单引号和非引号标识符编码的JSON吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以指示WCF接受使用单引号(而不是双引号)格式化的JSON:
Is there a way that I can instruct WCF to accept JSON that is formatted using either single quotes (as opposed to double quotes):
{
'foo': 'bar'
}
或使用非引用标识符,例如:
Or using non-quoted identifiers like so:
{
foo: 'bar'
}
照原样,似乎JSON仅在格式如下时才会被接受:
As it is, it seems like JSON will only be accepted if it is formatted like so:
{
"foo": "bar"
}
使用前两个示例中的任何一个都会产生400(错误的请求).
Using either of the first two example results in a 400 (bad request).
推荐答案
前两个示例是无效的JSON文本. http://www.ietf.org/rfc/rfc4627.txt
The first two examples are invalid JSON texts.http://www.ietf.org/rfc/rfc4627.txt
object = begin-object [ member *( value-separator member ) ]
end-object
member = string name-separator value
string = quotation-mark *char quotation-mark
quotation-mark = %x22 ; "
这篇关于WCF可以接受使用单引号和非引号标识符编码的JSON吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!