hi, i agree with lars and david that there is no question how the escaping is done. http://www.json.org/ defines this very clearly: http://www.json.org/string.gif
when writing json through a standardized json-writer and reading it with a standardized reader, there should not be any problem. regards, toby btw: in esp, it should be as simple as calling: object.toSource() On 1/22/08, Lars Trieloff <[EMAIL PROTECTED]> wrote: > Hi Everyone, > > I'm just catching up with the discussion and think that we should make > sure to use properly escaped quotation marks, backslashes and > apostropes (which can be easily implemented using a Reader) instead of > relying on urlencode. The more portable and standard-compliant > solution is not so hard to implement that it would justify deviating > from the standard. > > So, simply replace " with \" > ' with \' > and \ with \ > > For everyone who is interested in overriding JSON output in an JS or > ESP, we should provide a helper method writeJSON() that will take a > Javascript Object and write it as JSON to the output stream, because > encoding Javascript in Javascript will lead to unnecessary confusion > and clutter. > > regards, > > Lars > > > On 22.01.2008, at 15:03, Peter Svensson wrote: > > > Hi, > > > > Well, I think that the need for escaping chars exist because json is > > itself > > just text, and if a proeprty value contains a lot of """" here and > > there for > > instance, it will bork the value and also the client-side javascript > > parsing. > > > > This is normally no problem for simple values, when using Sling as a > > database of sorts, but as part of my Sling resource editor, I'd liek > > to be > > able to insert HTML code inside a node, which contains a lot of > > quotes, and > > possibly even JavaScript. > > > > So, that's why. > > > > Cheers, > > PS > > > > On Jan 22, 2008 2:56 PM, David Nuescheler <[EMAIL PROTECTED]> wrote: > > > >> hi guys, > >> > >> i am still somewhat confused why we are looking into the whole > >> escaping issue. was there an actual issue at hand? > >> > >> so far i have not experienced any issue with the current "escaping" > >> and i really would stay away from something like url escaping... i > >> simply > >> don't see a need. > >> am i mistaken? > >> > >> btw: i am happy to remove the quotes from names that don't need > >> the quotes. > >> > >> regards, > >> david > >> > >> > >> On 1/22/08, Peter Svensson <[EMAIL PROTECTED]> wrote: > >>> Ahem. :) I kind of assumed that the "sling:resourceType" property > >>> was > >> magic, > >>> and anything inside it would something that could be rendered in a > >> browser. > >>> Maybe not. > >>> > >>> I think that one of the problems in learning Sling is that it > >>> seems to > >> be > >>> infinitely configurable, so that you can add renderers for things > >>> on the > >>> fly, et.c. But if I say it this was; If there is some kind of > >>> basic type > >> in > >>> Sling for content to be consumed in a browser, then that could > >> reasonably be > >>> decalured to be of type urlencoded String. Would that be OK. > >>> > >>> Also, for my current project (Bunkai editor for Sling), I don't > >>> really > >> need > >>> the content int he json structure, I only need the hierarchical > >> structure, > >>> in array format already described, and some unique id/name that I > >>> can > >> use > >>> later, when a treenode (in Dojo) is sleected, to get the actual > >>> content. > >>> > >>> Cheers, > >>> PS > >>> > >>> On Jan 22, 2008 12:07 PM, Bertrand Delacretaz <[EMAIL PROTECTED] > >>> > > >>> wrote: > >>> > >>>> On Jan 22, 2008 11:53 AM, Peter Svensson <[EMAIL PROTECTED]> > >>>> wrote: > >>>> > >>>>> ...The 'meaning' of a property value is application domain > >>>>> specific > >>>> anyway, so > >>>>> I think we can choose any encoding type which is reasonably > >>>>> simple, > >> as > >>>> long > >>>>> as it is documented clearly.... > >>>> > >>>> But how do you decide (in the general case, with the default JSON > >>>> renderer) which properties to escape() and which to send out > >>>> unescaped? > >>>> > >>>> And how do you tell the client (dont' say "configuration" > >>>> please ;-) > >>>> which ones are escaped? > >>>> > >>>> -Bertrand > >>>> > >>> > >> > > -- > Lars Trieloff > [EMAIL PROTECTED] > http://weblogs.goshaky.com/weblogs/lars > > -- -----------------------------------------< [EMAIL PROTECTED] >--- Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel T +41 61 226 98 98, F +41 61 226 98 97 -----------------------------------------------< http://www.day.com >---
