2015-06-22 13:11 GMT+02:00 Sergey Beryozkin <[email protected]>:
> Hi
>
> CXF JettisonProvider is only capable of supporting JAXB-generated events, it
> does not deal directly with JSONObjects.
> What is the problem you are seeing with JAXB ? Can not have a sequence
> starting immediately from "[" ? That should be possible to configure with
> JettisonProvider with properties like 'dropRootElement': true,
> dropElementsInXmlStream: false, serializeAsArray: true
Right: I can not have a sequence starting immediately from "["
My settings :
<property name="dropRootElement" value="true" />
<property name="supportUnwrapped" value="true" />
<property name="serializeAsArray" value="true"/>
<property name="ignoreEmptyArrayValues" value="true"/>
My JAXB class
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CardType", propOrder = { "line", "icc", "statusCode" })
public class CardType
{
@XmlElement(required = true)
protected String line;
@XmlElement(required = true)
protected String icc;
@XmlElement(name = "status_code")
protected String statusCode;
The call:
List<CardType> l = new ArrayList<CardType>();
...
....
this.client.path("/temp").postCollection(l, CardType.class);
and I send
{"cardType":[{"icc":8934077600006637935},{"icc":"22222222222222222222"}]}
I would like to send
[{"icc":8934077600006637935},{"icc":"22222222222222222222"}]
Extra: I don't know why it sendsthe first value without quotes ...
>
> Cheers, Sergey
>
>
> On 22/06/15 11:42, Jose María Zaragoza wrote:
>>
>> Hello:
>>
>> I would like to POST a JSON array to a REST service
>>
>> Something like
>>
>> [
>>
>> {
>> "name" : "xxxxx",
>> "value" : "111111"
>> },
>> {
>> "name" : "yyyyyy",
>> "value" : "222222"
>> }
>>
>> ]
>>
>> I'm using CXF 2.7.8 + Jettison 1.3.5
>>
>> I usually implement it by JAXB classes , but I don't get achieving it
>> If I try with a JSONArray
>>
>> this.client.path("/test/").post(myJSONArray)
>>
>> I get
>>
>> No message body writer has been found for class : class
>> org.codehaus.jettison.json.JSONArray
>>
>>
>>
>> Any idea ?
>>
>> Thanks and regards
>>
>