0

Assuming I have the following object:

var data =
[
{"x.y":"X Y"},
{"x.y.a":"X Y A"},
{"x.y.b":"X Y B"},
{"x.y.c":"X Y C"},
{"d.e":"D E"}
];

How can render them in HTML like the following with jQuery?

x:
 y:"X Y"
  a:"X Y A"
  b:"X Y B"
  c:"X Y C"
d:
 e:"D E"
Gundam Meister
  • 1,425
  • 2
  • 19
  • 29
  • What is the data? are you trying to create an array of nested object? If so, this is not correct. – zero point Jan 30 '16 at 02:00
  • The data is returned from an ajax call. It is an array of objects. I need to render them on the front end according to the json 'key' name. – Gundam Meister Jan 30 '16 at 02:02
  • 1
    It does not matter where the data is coming from. variable data does not have a valid structure. fix it and then we can have a nice loop to generate li list – zero point Jan 30 '16 at 02:08
  • look into this link: http://stackoverflow.com/questions/17546739/loop-through-nested-objects-with-jquery – zero point Jan 30 '16 at 06:05
  • { "x.y": "X Y", "x.y.a": "X Y A", "x.y.b": "X Y B", "x.y.c": "X Y C", "d.e": "D E" } – Gundam Meister Jan 30 '16 at 06:17

0 Answers0