JSFiddle - React, Tailwind, and code Playground
HTML
<div id="results"></div>
CSS
#results {
border: 1px solid red;
}
.id {
color: blue;
}
em {
color: green;
}
JavaScript
$(function() { // run after document load
// replace any doc field with matching hilited text
$.each(data, function(idx1, obj1) {
$.each(obj1.highlighting, function(idx2, obj2) {
$.each(obj1.response.docs, function(idx3, obj3) {
if (obj3.id == idx2) {
$.each(obj2, function(idx4, obj4) {
if (idx4 in obj3) {
obj3[idx4] = obj2[idx4];
}
});
}
});
});
});
console.log(data);
var res = "results:";
$.each(data, function(idx1, obj1) {
$.each(obj1.response.docs, function(idx3, obj3) {
res += "<br><br><span class='id'>" + obj3.id + "</span> : " + obj3.name + "<br>" + obj3.text;
});
});
$('#results').html(res);
});
var data = [{
"responseHeader": {
"status": 0,
"QTime": 27
},
"response": {
"numFound": 1, "start": 0, "docs": [
{
"domain_type": "RRAPPL",
"text": ["RRAPPL",
"ANDA-077908",
"ANDA-077908",
"2009-12-31T23:59:59Z",
"Advil",
"Hcorp Inc",
"1489240432871211008"],
"id": "ANDA-077908",
"APPL_SUMMARY_s": "ANDA-077908",
"APPL_STATUS_DATE_dt": "2009-12-31T23:59:59Z",
"PROD_DRUG_NAME_s": "Advil",
"SUBMITTER_NAME_s": "Hcorp Inc",
"_version_": 1489240432871211008,
},
{
"domain_type": "PROD",
"text": ["PROD",
"Advil-1",
"Advil - 10MG - Injecton, Emulsion",
"2009-12-31T23:59:59Z",
"Advil",
"Hcorp Inc",
"1489240432894279680"],
"id": "Advil-1",
...