This is not a direct answer to your question, but I believe that it can help you more than give you a sophisticated way to access the values ββin your object.
If instead of this JSON object:
var index_file = [{ "indexAB":[ { "postsome": ["keyword_abc", "keyword_def"] }, { "testsome": ["keyword_111", "keyword_222"] } ] },{ "index_random": [ { "postsome": ["keyword_abc"] } ] }];
you will have this much simpler data structure:
var index_file = { "indexAB": { "postsome": ["keyword_abc", "keyword_def"], "testsome": ["keyword_111", "keyword_222"] }, "index_random": { "postsome": ["keyword_abc"] } };
then it would be easier using only:
var value = index_file.indexAB.postsome[0]; // no loops, no nothing // value == "keyword_abc"
See: DEMO
I think that what you need to change is your data model, because currently it is very far from the idea of ββJSON, and it will always be very difficult to access data in it.
source share