The Stack Overflow podcast is back! Listen to an interview with our new CEO.

I used to do this with XML back in the day. The idea is that you give your clients a schema and you should guarantee that you follow it, otherwise you might cause an error. I agree with you though, Unit testing seem a better way of doing this for 99% of cases. You can imagine a complicated schema an a service which builds up a response with info from other ...


You might be able to use content-type parameters as in application/json; schema=foo application/json; schema=bar I don't know whether adding user-defined parameters is officially blessed, but as long as you're talking between your own pieces of software who is going to punish you?


I think your question may have been answered over at Stack Overflow. It involves using the spec for designing your JSON and converting it with Not sure if the github repo needs any updates for the current version of Java, but it might give you a good starting point.


When object serialization is involved a Data Transfer Object (as you mentioned) gives you the flexibility you need to mirror the JSON structure in an object oriented language. Each tech stack has a way to parse JSON into specific data formats (int's, strings, floats, structs, complex objects, arrays, etc). Once you have the DTO you are free to map this to ...

Only top voted, non community-wiki answers of a minimum length are eligible