Can WCF accept JSON encoded using single quotes and non-looped identifiers?

Is there a way I can give WCF the ability to accept JSON that is formatted using single quotes (as opposed to double quotes):

{ 'foo': 'bar' } 

Or using non-displayable identifiers:

 { foo: 'bar' } 

Be that as it may, it seems that JSON will only be accepted if it is formatted like this:

 { "foo": "bar" } 

Using one of the first two examples results in 400 (invalid request).

+1
json wcf
source share
2 answers

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 ; " 
+2
source share

DataContractJsonSerializer always writes strict JSON.

At different points during deserialization (usually there are no end tags for arrays or objects or incorrect escaping or incorrectly formatted numbers), it accepts an incorrect, non-strict JSON.

However, I can definitely tell you that this is not one of these cases. DataContractJsonSerializer always requires a double-quoted string for JSON.

Hope this helps!

+2
source share

All Articles