commercetools / commercetools-jvm-sdk

The e-commerce SDK from commercetools running on the Java virtual machine.
https://commercetools.github.io/commercetools-jvm-sdk/apidocs/index.html
Other
62 stars 40 forks source link

SphereJsonUtils.toJsonString map attribute "fields" in customType incorrectly #1214

Closed Saandji closed 8 years ago

Saandji commented 8 years ago

The problem: I have productProjection with list of Prices and each price has custom type. I use SphereJsonUtills.toJsonString(projection);

When i parse it back to ProductProjection i'm getting parse error.

After investigating a bit, i assume that the problem in the next fields:

this is the json of "custom" as it should be: "custom": { "type": { "typeId": "type", "id": "some_id" }, "fields": { "field1": 1, "field2": "value" } }

this what i get from SpehreUtils.toJsonString:

"custom": { "type": { "typeId": "type", "id": "some_id" }, "fieldsJsonMap": { "field1": 1, "field2": "value" } }

schleichardt commented 8 years ago

In the JVM SDK it is not supposed to get the API objects as JSON and then as Java and then transform the Java again into JSON.

If you need the Java object and JSON consider to use this class to get them both: http://commercetools.github.io/commercetools-jvm-sdk/apidocs/io/sphere/sdk/client/JavaAndJsonSphereRequest.html