How can I make object of RestAPI generic?

0
I am building a bitcoin app and I am getting the information from Rest service. In every request the main object changes. It is not generic. If I request with XYZ parameter it returns XYZ Object. How can I map this and make it generic ?        Thanks.
asked
2 answers
0

A, i see.

One possible approach:

Fill the json structure in Mendix with a json example message that contains all possible variants in one message. In the domain model, you create your generic entity and in the mapping use the same generic entity as mapping target for each of the accorances of ETC, ETH etc.

Another option, one i prefer but requires cooperation of the source of the data:

Ask the source of the json to change the format, because the format seems to be more suited for something like:

“data” : {

   “genericitem”: {

      “type” : “ADA”,

      …….

}

}

Other options are possible, but may require string manipulation before having it processed by Mendix, so that would be a last resort because of complexity.

I hope this helps.

answered
0

Hi Michiel,

I have already done mapping for BTC,ETH. However, when user enters different parameters, response body is different as you see below. How can I handle this situation in import mapping? I cannot map all coins in import mapping ,it is not useful.

I hope, this is more clear.

  

 

Thanks.

answered