I have a JSON object consisting of strings for the name and arrays for the value. Given a string within one of the arrays, how can I find the name it belongs to?
Example: Given the following JSON object, how can I use jQuery to get the answer “G1” when given the string “1” or “G2” when given the string “4”?
{
"G1": [ "1" , "2" ],
"G2": [ "3" , "4" ]
}
I’ve made a JSFiddle with my current work: http://jsfiddle.net/JmX6b/
1 Answer