locked
How to get encapsulated string included solidus('/') on json? RRS feed

  • Question

  • How to get encapsulated string included solidus('/') on json?



    there is json code and the result is what i don't want
    ------------------------------------------------------------------------
    JsonObject Value = new JsonObject();
    Value.Add("Value", JsonValue.CreateStringValue("http://example.org"));
    Debug.WriteLine(Value.Stringify());


    the result is what i don't want --->    {"Value":"http://example.org"}

    ------------------------------------------------------------------------



    i want to get encapsulated string like below, how to get the string?
    ------------------------------------------------------------------------
    {"Value":"http:\/\/example.org"}
    ------------------------------------------------------------------------


    Thursday, November 6, 2014 8:48 AM

Answers

  • Why do you want to escape the slashes?

    According with the JSON RFC, the slash (0x2F) in hexadecimal does not require to be escaped:

    string = quotation-mark *char quotation-mark
    
    char = unescaped /
      escape (
          %x22 /          ; "    quotation mark  U+0022
          %x5C /          ; \    reverse solidus U+005C
          %x2F /          ; /    solidus         U+002F
          %x62 /          ; b    backspace       U+0008
          %x66 /          ; f    form feed       U+000C
          %x6E /          ; n    line feed       U+000A
          %x72 /          ; r    carriage return U+000D
          %x74 /          ; t    tab             U+0009
          %x75 4HEXDIG )  ; uXXXX                U+XXXX
    
    escape = %x5C              ; \
    
    quotation-mark = %x22      ; "
    
    unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
    



    Thursday, November 6, 2014 3:51 PM