Loading ...
Sorry, an error occurred while loading the content.

821Re: Hello all I am new to json so I have a few questions

Expand Messages
  • marcrbraincast
    Jun 27, 2007
      --- In json@yahoogroups.com, "Dan Joseph" <dmjoseph@...> wrote:
      > I am new to some of this so I might not be clear, I am woking with
      > > ajax and I am getting a string returned from another webpage that is
      > > JSON encoded. When I recieve it it is then consittered a string. I
      > > would like to take this returned string
      > > {"outPut":[{"name":"Michelle Gallagher"},{"name":"Bob Jones"},
      > > {"name":"tester"},{"name":"Administrator"}]}
      > > and put it back into a javascript object. Can I do that with decode?
      > >
      > > _._,___
      > >
      > ---------------------
      > I think you might be looking for eval(). Here is what I do with my json
      > requests:
      > { "errors" :
      > [
      > { "code" : "OK" }
      > ];
      > "cells" :
      > [';
      > { "cell" : "none" }
      > ] }
      > var j = eval('('+ xmlhttp.responseText +')');
      > And then they are accessible in the form of: j.errors[0].code so if
      I do an
      > alert( j.errors[0].code ); I'd get OK (the value of code). I'm
      pretty new
      > to this also, so you may want to take my brief example and search around
      > yahoo and google for a similar more in depth tutorial.
      > --
      > -Dan Joseph
      > "Build a man a fire, and he will be warm for the rest of the day.
      > Light a man on fire, and will be warm for the rest of his life."
      > [Non-text portions of this message have been removed]

      Hi Guys,

      That would mean that you are letting javascript evaluating possible
      unsafe json... thats why you should either use json.js from Douglas
      (http://www.json.org/json.js) or the JSON.js from devpro.it...

      If the json object/string is safe because you are generating it or it
      comes from a safe source... then by all means use eval()...

      I am unfamiliar with the JSON.js library so I would say give it a go
      with the JSONError.js in there as well... if it still gives problems
      you might want to use http://www.jslint.com/lint.html to check the
      json... otherwise, why don't you ask the guy from devpro.it?

      And then there's always the possibility to just post as much code as
      you are willing to share with the json so we can test it and see what
      errors you are getting ;p
    • Show all 15 messages in this topic