1

I have this Js Obect, I need to trim/remove one set of square braces "the outermost ones [ ]" from the object . Below is the structure:

[[{"id":"5","color":"red",nges":[{"monthindex":3},{"monthindex":3"}]},{"id":"5","color":"red""nges":[{"monthindex":3"},{"monthindex":3"}]}]]

How can this be done , I did via PHP before sending it to JS but that didn,t help.

1
  • 5
    I'm voting to close this question as off-topic because it is not related to the Magento platform.
    – Ben Crook
    Sep 18, 2017 at 8:49

1 Answer 1

1

Besides that your JavaScript object is invalid, why wouldn't a simple newObj = oldObj[0] work?

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.