Pages

Wednesday, July 13, 2011

Creating JSON object in WCS

Websphere Commerce provides a jsp tag to make it simple to generate a JSON object. For example, a product JSON might have to be created depending on the business requirements.

The details of the jsp tag is given below
<wcf:json object="${productJSON}"/>

where productJSON is an object (generally a Map) which gets converted to a JSON object.

Map contains key value pairs which are translated to JSOn as below

{
   Map {
         color: red
         price:20
}
}

2 comments:

  1. Does this work for plain POJO's too?

    ReplyDelete
  2. if the values have "&" they are converted to & how to avid this ?

    ReplyDelete