[Proto-Scripty] Re: Problem with evalJSON in Prototype 1.7

2011-02-27 Thread pablopazos
Thanks a lot for your answer T.J., definetly your know how to give
complete and useful answers.

Kind regards,
Pablo Pazos.
http://yuppframework.blogspot.com


On 25 feb, 10:47, "T.J. Crowder"  wrote:
> Hi Pablo,
>
> Your JSON is incorrect. Key names *must* be in double (not single)
> quotes, and strings must be in double (not single) quotes:http://json.org
>
> Many "JSON" parsers are lax and let you get away with things, because
> they're really just thin wrappers around JavaScript parsers (via
> `eval`), and your code is valid JavaScript object literal notation.
> But it's considered bad practice to use `eval` to process JSON and the
> trend is to move away from it to genuine JSON parsers, which are more
> strict. I don't know it for a fact, but it sounds like 1.7 moved to a
> strict parser.
>
> Here's a valid version of your JSON:
> * * * *
> {
>   "comentarios":
>     [
>       {
>         "texto" : "sdfadfadfadfasdf",
>         "fecha" : "2011-02-11 23:24:13",
>         "class" : "Comentario",
>         "deleted" : "",
>         "entrada_id" : "1",
>         "usuario_id" : "",
>         "id" : "2"
>       },
>       {
>         "texto" : "asdfasdfasdfasdfasdfasdf",
>         "fecha" : "2011-02-11 23:24:17",
>         "class" : "Comentario",
>         "deleted" : "",
>         "entrada_id" : "1",
>         "usuario_id" : "",
>         "id" : "3"
>       }
>     ]}
>
> * * * *
>
> Note that you don't have to put numbers in quotes, though. I've left
> them in qutoes because for all I know, you want them to be strings,
> but I thought I'd mention it.
>
> This site is useful for validating your JSON:http://www.jsonlint.com/
>
> HTH,
> --
> T.J. Crowder
> Independent Software Engineer
> tj / crowder software / com
> www / crowder software / com
>
> On Feb 24, 3:21 pm, pablopazos  wrote:
>
> > Hi, I've updated my v1.6.1 Prototype to the new v1.7.
>
> > In 1.6.1 I have this (**) JSON string parsed correctly, but in v1.7
> > I'm getting a Parse Error when I call evalJSON() on the JSON string.
> > The JSON format seems to be correct, so I think something is broken in
> > v1.7.
>
> > (**)
>
> > {
> >      'comentarios':
> >      [
> >       {
> >        'texto' : 'sdfadfadfadfasdf',
> >        'fecha' : '2011-02-11 23:24:13',
> >        'class' : 'Comentario',
> >        'deleted' : '',
> >        'entrada_id' : '1',
> >        'usuario_id' : '',
> >        'id' : '2'
> >       },
> >       {
> >        'texto' : 'asdfasdfasdfasdfasdfasdf',
> >        'fecha' : '2011-02-11 23:24:17',
> >        'class' : 'Comentario',
> >        'deleted' : '',
> >        'entrada_id' : '1',
> >        'usuario_id' : '',
> >        'id' : '3'
> >       }
> >      ]
> >     }
>
> > Cheers,
> > Pablo.http://yuppframework.blogspot.com/
>
>

-- 
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 prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: Problem with evalJSON in Prototype 1.7

2011-02-25 Thread T.J. Crowder
Hi Pablo,

Your JSON is incorrect. Key names *must* be in double (not single)
quotes, and strings must be in double (not single) quotes: http://json.org

Many "JSON" parsers are lax and let you get away with things, because
they're really just thin wrappers around JavaScript parsers (via
`eval`), and your code is valid JavaScript object literal notation.
But it's considered bad practice to use `eval` to process JSON and the
trend is to move away from it to genuine JSON parsers, which are more
strict. I don't know it for a fact, but it sounds like 1.7 moved to a
strict parser.

Here's a valid version of your JSON:
* * * *
{
  "comentarios":
[
  {
"texto" : "sdfadfadfadfasdf",
"fecha" : "2011-02-11 23:24:13",
"class" : "Comentario",
"deleted" : "",
"entrada_id" : "1",
"usuario_id" : "",
"id" : "2"
  },
  {
"texto" : "asdfasdfasdfasdfasdfasdf",
"fecha" : "2011-02-11 23:24:17",
"class" : "Comentario",
"deleted" : "",
"entrada_id" : "1",
"usuario_id" : "",
"id" : "3"
  }
]
}
* * * *

Note that you don't have to put numbers in quotes, though. I've left
them in qutoes because for all I know, you want them to be strings,
but I thought I'd mention it.

This site is useful for validating your JSON: http://www.jsonlint.com/

HTH,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

On Feb 24, 3:21 pm, pablopazos  wrote:
> Hi, I've updated my v1.6.1 Prototype to the new v1.7.
>
> In 1.6.1 I have this (**) JSON string parsed correctly, but in v1.7
> I'm getting a Parse Error when I call evalJSON() on the JSON string.
> The JSON format seems to be correct, so I think something is broken in
> v1.7.
>
> (**)
>
> {
>      'comentarios':
>      [
>       {
>        'texto' : 'sdfadfadfadfasdf',
>        'fecha' : '2011-02-11 23:24:13',
>        'class' : 'Comentario',
>        'deleted' : '',
>        'entrada_id' : '1',
>        'usuario_id' : '',
>        'id' : '2'
>       },
>       {
>        'texto' : 'asdfasdfasdfasdfasdfasdf',
>        'fecha' : '2011-02-11 23:24:17',
>        'class' : 'Comentario',
>        'deleted' : '',
>        'entrada_id' : '1',
>        'usuario_id' : '',
>        'id' : '3'
>       }
>      ]
>     }
>
> Cheers,
> Pablo.http://yuppframework.blogspot.com/

-- 
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 prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.