wrynn
asked on
How to serialize array of custom objects and post as json with jax-rs ClientBuilder?
I'm trying to figure out how to serialize an array of java objects and post as json with jax-rs ClientBuilder using jersey and/or jackson.
I'm using the ClientBuilder to do a post. If for example you have an Arraylist of Car objects
I'm using the ClientBuilder to do a post. If for example you have an Arraylist of Car objects
List<Car> cars = new ArrayList<>();
And I want to do something like:Response response = ClientBuilder
.newClient.target(url)
.request()
.accept(MediaType.APPLICATION_JSON)
.post(Entity.json(cars));
and post exactly this as the payload[{"brand": "toyota"}]
How would I need to implement the Car object? And how would I need to setup my ClientBuilder chain properly?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window
and then
Open in new window