How to sends multiple object over JSON from sitebricks client to sitebricks REST Service?

196 views Asked by At

Is it possible to sends two or more object simultaneously from sitebricks client to sitebricks service ?

For example, I have a Person Object and a JobApplication Object. Can I do something like this:

public class ApplicationStorage {

    @Post
    public void post(Person person, JobApplication job) {
        // ...
    }    
}

WebClient client = web.clientOf("service url") ..... // here how to send the two objects ? 
2

There are 2 answers

1
ecbrodie On BEST ANSWER

If sending two objects is a must, then create another object that is composed of the two objects that you wish to send over HTTP. Your JSON parser (ex: Jackson) will be able to serialize each of the first two objects into JSON, and set them as JSON attributes to your new object.

0
Dhanji R. Prasanna On

You can send a List too, but this is not ideal as you have to mess about with Java Generics. The wrapper object is the best way.