Can people define one Java model for all the MultiChain’s reply?Thanks.

+1 vote
When I call MultiChain API command, is there any uniform format for MultiChain’s reply? So I can define one Java model for all the results. Or is it different format for different API command?
asked Jul 5, 2016 by Helen

1 Answer

0 votes
The responses are all in JSON format, so if you find a Java library for decoding JSON, it should make the MultiChain API quite easy to use.
answered Jul 7, 2016 by MultiChain
Thanks. I have 2 further questions.
1) For all the MultiChain API command, when we get the reply. After decoding JSON, I am considering the unified Java object for the response. Is it possible?  
No matter whether we get success or failure result, we will always have the field “result”, “error” and “id”? Is the understanding right?

2) Is it possible to have a unified Java object for the MultiChain request?
I am think all the request needs and only needs these field ”method”,”params” ,”id” ,”chain_name”. Is it correct? Thanks.
I'm not sure what you mean by "unified Java object". But you should always have the field "id", and a "result" or "error" depending on whether the call was successful.
Hi Helen,
Yes it's possible to create a generic pojo to request data and read data.
The request pojo it's easy and needs only the params that you described, the response pojo it's a bit more complex but if you use generics should not be hard to do it.