Integrating Product Comparison via JSON
$stringEscapeUtils.escapeHtml($body)
The only difference between calling the JSON interface and calling the XML interface is in the parameter format=json
. Otherwise the URL parameters and request options are the same – please see the previous section of this documentation for a description.
The definition of the JSON schema can be found under the following URL:
$stringEscapeUtils.escapeHtml($body)
And the output format might look like this:
{
"attributes": [
{
"attributeName": "Manufacturer",
"different": false,
"sourceField": "manufacturers_name"
},
{
"attributeName": "Model year",
"different": true,
"sourceField": "products_model_year"
},
...
],
"records": [
{
"id": "17959",
"record": {
"Model year": "2009",
"Manufacturer": "Corratec",
...
}
},
...
]
}
The output comprises two lists. The list under attributes provides information on comparable attributes. Each element in this list contains the attributes: attribute name, field name containing the attribute (sourceField
) and a flag stating if the attribute values of the products differ. The second list in the output contains all products that were compared. The structure of the individual elements is similar to that of the search results.