javascript - How can i separate the second set from this object? -
i've javascript map in separate last set of objects,
{ "97483": { "_index": 0, "text_html": "sadf" }, "97484": { "_index": 1, "text_html": "sfhsdfasdfsdf" }, "97485": { "_index": 2, "text_html": "test1" }, "97486": { "_index": 3, "text_html": "test2" }, "97487": { "_index": 4, "text_html": "test3" }, "97493": { "_index": 0, "text_html": "test9" }, "97494": { "_index": 1, "text_html": "test10" }, "97495": { "_index": 2, "text_html": "test11" }, "97496": { "_index": 3, "text_html": "test11" }, "97893": { "_index": 0, "text_html": "test99" }, "97894": { "_index": 1, "text_html": "test999" }, "97895": { "_index": 2, "text_html": "test9999" }, }
in javascript map how can separate out the
"97893": { "_index": 0, "text_html": "test99" }, "97894": { "_index": 1, "text_html": "test999" }, "97895": { "_index": 2, "text_html": "test9999" },
actually main motive separate out last set of elements _index starts 0. appreciated.
try write code like,
var mainobj = {...}; //your object var result = {}; object.keys(mainobj).foreach(function(itm){ if(mainobj[itm]._index == 0) result = {}; result[itm] = mainobj[itm]; });
the above code collect last set of objects main object.
Comments
Post a Comment