Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Warning evaluating a JSON string.

I have an array of JSON strings. When the application try to evaluate them like

var x = eval(Posts[4])

where Posts is the array of JSON strings. I receive a warning dialog that ask me to kill the process or continue. The dialog says the following text.

"Calling eval() with anything other than a primitive string value will simply return the value. Is this what you Intended?"

If I click continue it will continue the execution of the application and works fine. Inclusive the eval() return the correct data even-though there was a warning.

Is there any way to remove that warning? Does I'm doing something wrong?

— asked September 13th 2010 by Miguel Gandia
  • android
  • eval()
  • json
  • mobile
0 Comments

2 Answers

  • Try using

    var x = JSON.parse(Posts[4]);
    
    — answered September 13th 2010 by Satta Ravi
    permalink
    1 Comment
    • Thanks for the response. When I use JSON.parse it has an error of "IllegalArgumentException: argument type mismatch"

      This is the object that I'm using.

      http://pastie.org/1155618

      and this is the value of one of the instances of the array.

      http://pastie.org/1155624

      The error is when this is called myPosts.ImageURL(a)

      Regards,
      Miguel

      — commented September 13th 2010 by Miguel Gandia
  • I solve my problem changing the way of the "JSON" arrray. Now is a Class array. This is the final code…

    http://pastie.org/1155816

    — answered September 13th 2010 by Miguel Gandia
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.