Searched and tried with no luck, I guess it's time to ask ;-)
A JSON array is sent with Objects as items, inside each object, there are values associated with keys, i.e.
[{"name":"Jack", "message":"Hello!"},
{"name":"John", "message":"Hi!"},
{"name":"Jack", "message":"Hello Again!"}]
I am using
$.each(json, function(){//--Do a Listing--//});
which renders a list like:
<ul>
<li><span>Jack:</span>Hello!</li>
<li><span>John:</span>Hi!</li>
<li><span>Jack:</span>Hello Again!</li>
</ul>
as looping all items out. However, if you have noticed that inside the JSON package, there will be duplicated keys - 'name' which I would like, instead of making a separated listing item, to make them stack together, e.g. to display as 'Jack +1' which is something like:
<ul>
<li><span>Jack: (+1)</span>Hello!</li>
<li><span>John:</span>Hi!</li>
</ul>
So far, the looping is not a problem. The problem is how to compare the value with the same key while looping them out and then do something with them.
Thanks in advance!