JSFiddle - React, Tailwind, and code Playground
HTML
<div id="matched"></div>
<div id="json">{
"CacheName":"Default",
"LastUpdateTime":"\/Date(1396994130568)\/",
"Type":"Start",
"TotalItemsCount":3,
"PassingFilterCount":3,
"ItemValues":[
{
"Fields":{
"id":"13288263",
"status":"8",
"x_cord":"7250600",
"y_cord":"566620200",
"code":"1021",
"sub_code":"1W",
"priority":"1",
"units":"1011, 1130, 1201, 1233, 1445, 1501, 1518, 1714, 1726, 1823, 1825, 1832, 3662",
"ts":"20140402234025UT"
},
"Id":"13288263",
"LastAction":"add"
},
{
"Fields":{
"id":"13288264",
"status":"8",
"x_cord":"",
"y_cord":"",
"code":"",
"sub_code":"",
"priority":"-1",
"units":"",
"ts":""
},
"Id":"13288264",
"LastAction":"add"
},
{
"Fields":{
"id":"13288265",
"status":"8",
"x_cord":"",
"y_cord":"",
"code":"",
"sub_code":"",
"priority":"-1",
"units":"",
"ts":""
},
"Id":"13288265",
"LastAction":"add"
}
]
}</div>
JavaScript
//The json is in the html here, to avoid overwhelming this section
var json_string = document.querySelector("#json");
//Use JSON.parse to make it an object
var json_object = JSON.parse(json_string.innerHTML);
//And remove the json in the html
json_string.remove();
//Will store the matched div
var matched_div = document.querySelector("#matched");
var x = 13288263;
$.each(json_object.ItemValues, function(key, item_value){
if(item_value.Fields.id == x){
matched_div.innerHTML = item_value.Fields.id;
//Second part of the question
var units = item_value.Fields.units;
if(units != ""){
var units_array = units.split(', ');
alert(units_array);
}
}
});