My data is originally stored in a MySQL database in the following format...
{'profile':'sweet', 'count':38},{'profile':'bitter', 'count':31},{'profile':'green', 'count':22}
When I retrieve it as JSON through Express, it appears like this...
[{"JSON":"{'profile':'sweet', 'count':38},{'profile':'bitter', 'count':31},{'profile':'green', 'count':22}"}]
This JSON structure has been validated on JSONLint.com.
The challenge arises when trying to iterate over this data using JavaScript in HTML...
Here is my current JavaScript code....
fProfiles_JSON = JSON.parse(xhr.responseText);
console.log('Type of '+ typeof fProfiles_JSON); //results in "object"
console.log('My object', fProfiles_JSON);
console.log('LENGTH ', fProfiles_JSON.length); // Returns "1"
I understand that I need to find a way to loop through this object to access the values for "profile" and "count", but I'm unsure how to proceed due to the length being "1". I realize this may be a simple solution that I am overlooking. Can anyone provide guidance on where to start?