Reputation: 13679
I want return a dynamic JSON object from my endpoint, to add properties on the fly without changing any method signature.
Upvotes: 2
Views: 464
Reputation: 17884
It feels rather contrary to the design of endpoints, but I found it very useful to have endpoints that could accept or return arbitrary JSON objects. So I use a class like this in my endpoint method:
public class DataParcel {
public Integer obj_type = -1;
public List<String> json_objects = null; // new ArrayList<String>();
The only complication is which JSON library to use - the JSON encoding/decoding is no longer done for you automatically.
Upvotes: 1