Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

JSON.parse not working if there is an underscore in the name

$
0
0

So, I was having some trouble accessing some of the values in a JSON object. I have tracked it down to names in the object that contain underscores. When I make an API call in a browser, I get a valid JSON object. I call it in Titanium, and run JSON.parse on it. I can access values normally, except those where the name has an underscore.

Example, Object[i].name gives me the name Object[i].date_end gives me nothing

When I log the parsed object in the console, what I see is:

{ name = "This is a Name" "date_end" = "Date" }

So the parsed object is leaving quotes around all of the names that have an underscore in them, even though they are valid part of a JSON name. I have a large object that's around 50/50 with and without underscores. So I can't access half the data (and I need all of it).


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>