MLak
MLak

Reputation: 115

JSON Payloads with Spaces in Attribute Names‏

I am having some trouble with WSO2AM-1.7. When I try to GET a resource such as:

{
      "hello there" : "world"
}

The mediation step does not work, because of the space in "hello there". I know XML element types cannot contain spaces in their names, and the error I'm getting suggests that's precisely what the program is trying to do. This must mean that the data is implicitly changed to XML, even though all my data is supposed to stay in JSON.

I am using the messagebuilder and formatters:

<messageFormatter contentType="application/json"
                          class="org.apache.synapse.commons.json.JsonStreamFormatter"/>

<messageBuilder contentType="application/json"
                        class="org.apache.synapse.commons.json.JsonStreamBuilder"/>

Is there another message builder or formatter I should be using instead?

Upvotes: 2

Views: 466

Answers (1)

Jenananthan
Jenananthan

Reputation: 1401

You can find about message builders and formatters here.

org.apache.synapse.commons.json.JsonStreamBuilder
org.apache.synapse.commons.json.JsonStreamFormatter

will keep the keep the JSON representation intact without converting it to XML.

I have gone through same scenario in APIM 1.8 where my json has space attribute.But it worked fine without any error (couldn't check with APIM 1.7).

Upvotes: 2

Related Questions