collection service the 'EditLink' string in JSON not pretty !

Last post 06-22-2009 10:30 PM by cosophy@gmail.com. 4 replies.

Sort Posts:

  • collection service the 'EditLink' string in JSON not pretty !

    06-13-2009, 2:23 AM

    In all JSON returns of my collection services, the char "/" in the 'EditLink' string changes to "\/" (it is '\' and '/', not "V"), are yours the same? It does not look pretty. Anyone knows why and has any idea how to make it back to '/'?

  • Re: collection service the 'EditLink' string in JSON not pretty !

    06-19-2009, 7:19 PM
    Answer

    Hello,

    This MSDN topic metnions that all instances of / will always be escaped  when you use the WCF JSON serializer. The reason for that is rather complex but has to do with the way the DateTime type is serialized. I don't think there is a way to get the serializaer to behave differently.

    However upon calling eval in JavaScript on the client side \/ will corectly turn into /, so it souldn't be a problem.

    Thanks,
    -Yavor

    If this answers your question, please mark as answered.

    Program Manager | Silverlight Web Services Team | Microsoft
  • Re: collection service the 'EditLink' string in JSON not pretty !

    06-22-2009, 9:32 AM

    Thank you! Yavor,

    You mean we can not change this?  And when I consume the service in Ajax using XMLHttpRequest, the ResponseText still includes \/ . How did you do that? Thanks in advance.

    Allen

     

     

  • Re: collection service the 'EditLink' string in JSON not pretty !

    06-22-2009, 1:49 PM

    I don't think you can change it. The string will still include \/ but when you call eval() on the string in JavaScript it should turn into a single slash like you expect. That's usually the pattern for using a JSON string in JavaScript.

    Thanks,
    -Yavor

    If this answers your question, please mark as answered.

    Program Manager | Silverlight Web Services Team | Microsoft
  • Re: collection service the 'EditLink' string in JSON not pretty !

    06-22-2009, 10:30 PM

     Thanks Yavor,

    I've got it. But i still expect the JSON response gets normal, hoping MS will concern this small problem.

Page 1 of 1 (5 items)