SAP Knowledge Base Article - Preview

2370355 - How to return collection with single element in correct JSON format via hybris platformwebservices

Symptom

When getting items e.g. product via Platformwebservices and the item contains collection which have only one element e.g. if a Product only has one Price Row, then the json representation of the collection is a JSON Object:

 

"europe1Prices": {

"priceRow": {

"@pk": "8796093153313",

"@uri": "http://localhost:9001/lionplatformwebservices/rest/pricerows/8796093973535"

},

"price": "120.0"

}

 

When the collection has more than one element then the json being returned is an array:

"europe1Prices": {

 "priceRow": [

     {

        "@pk": "8796113110047",

        "@uri": "http://localhost:9001/ws410/rest/pricerows/8796113110047"

      },

      {

        "@pk": "8796113208351",

        "@uri": "http://localhost:9001/ws410/rest/pricerows/8796113208351"

      }

    ]

 }

This is an issue if client code is expecting an array which leads to not being able to consume related data using a single e.g. JavaScript client. 


Read more...

Environment

SAP hybris V4,V5

Product

SAP hybris Commerce 5.0.3 ; SAP hybris Commerce 5.0.4 ; SAP hybris Commerce 5.7 ; SAP hybris Commerce Suite 5.2 ; SAP hybris Commerce Suite 5.3 ; SAP hybris Commerce Suite 5.4 ; SAP hybris Commerce Suite 5.5 ; SAP hybris Commerce Suite 5.5-1 ; SAP hybris Commerce Suite 5.6 ; hybris Commerce Suite 4.4 ; hybris Commerce Suite 4.5 ; hybris Commerce Suite 4.6 ; hybris Commerce Suite 4.7 ; hybris Commerce Suite 4.8 ; hybris Commerce Suite 5.0 ; hybris Commerce Suite 5.1 ; hybris Commerce Suite 5.1.1

Keywords

hybris, platformwebservices, json, array, collection, single, object , KBA , CEC-COM-CPS , Commerce Platform & Suite (SAP Commerce) , Problem

About this page

This is a preview of a SAP Knowledge Base Article. Click more to access the full version on SAP ONE Support launchpad (Login required).

Search for additional results

Visit SAP Support Portal's SAP Notes and KBA Search.