如何转换此 JSON 对象:
"context":{"#text":["Most Visited Pages ","
Hall Residents Advanced Components"," Clerk"],"highlight":["City","City"]}
进入:
Most Visited Pages <highlight>City</highlight>
Hall Residents Advanced Components <highlight>City</highlight> Clerk
通过使用Javascript?
我试过了:
function highlightContext_22(context) {
var highlighted;
$.each(context['#text'], function(key, val) {
highlighted += val + val.highlight;
});
return highlighted;
}
输出是:
undefinedMost Visited Pages undefined
Hall Residents Advanced Components undefined Clerkundefined