Open mobilefocustoar opened 6 years ago
Hi, Is my question stupid?
Hi. Did you create Response object like this?
const response = new Response(JSON.parse(serverResponse));
Castable don't change json responses directly.
Regards.
Thanks for your response.
Yes, I create response like above. I want to confirm that above is right.
Regards.
I want to know how program code when root of response is array.
Thank you.
const parsedArray = (JSON.parse(serverResponse) as Array<unknown>).map(
(elem) => new Response(elem)
);
How are you. I think that this library is useful.
But, I have a problem in programming. I need your help.
If the result is json object, and it is simple: { "type":"xxx", "currency":"btc", "amount":"0.0", "available":"0.0" }
class is following: export class Response extends Castable { @cast type: string; @cast currency: string; @cast amount: number; @cast available: number; }
But json response is array. There is no key. the json response is following: [{ "type":"xxx", "currency":"btc", "amount":"0.0", "available":"0.0" },{ "type":"xxx", "currency":"usd", "amount":"1.0", "available":"1.0" },{ "type":"xxx", "currency":"btc", "amount":"1", "available":"1" }]
what is class for castable? Please teach me.
Regards.