Hi, > ...I getting "Error sintax" but If > I remove the When Value with the date the evalJSON works without any > problem does any know why is this...
Because you're giving invalid JSON. (JSONLint.com is useful for checking.) JSON has no `new` operator, and no concept of `Date`s: http://json.org If you want to _extend_ JSON to include Dates, you'll need to use a JSON parser that understands the concept of a "reviver" helper function (AFAIK, Prototype's `parseJSON` doesn't), and you'll need to supply a "reviver" helper that understands the kinds of date information you'll be throwing at it. Crockford (the inventer of JSON) has three JSON parser implementations, all of which I believe support using a "reviver": https://github.com/douglascrockford/JSON-js The `json2.js` version does some security checks and uses `eval` under- the-covers. If you're not comfortable with that, you can use `json_parse.js` or `json_parse_state.js`, neither of which uses `eval`. The former is a recursive-descent parser, the latter is a state machine. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jan 6, 6:27 pm, ncubica <[email protected]> wrote: > Hi I'm working with the evalJSON method many time before but some > reason now is sending me a "Error Sintax" when I try it to use with > any Date format. > > the json string which I'm receiving in the responseJSON is the follow. > > [{"Aspirante_id":37,"AspirantesComentarios_id": > 6,"Comentario":"asdfadsf","Who":"nahum","When":new > Date(1294268679000)}] > > I'm doing something like "[{"Aspirante_id": > 37,"AspirantesComentarios_id": > 6,"Comentario":"asdfadsf","Who":"nahum","When":new > Date(1294268679000)}]".evalJSON(); and I getting "Error sintax" but If > I remove the When Value with the date the evalJSON works without any > problem does any know why is this, do I'm doing something wrong, Im > working this with Newtosoft and C#. > > Code C# is a webmethod > var commentsFound = from comment in > aspirantescomentario.All() where comment.Aspirante_id == > Convert.ToInt32(id) orderby comment.When descending select new > { comment.Aspirante_id, comment.AspirantesComentarios_id, > comment.Comentario, comment.Who, comment.When }; > var js = JsonConvert.SerializeObject(commentsFound,new > JavaScriptDateTimeConverter()); > Context.Response.Output.Write(js); > Context.Response.End(); > return string.Empty; -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
