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

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 ...


2

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?


1

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


1

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