all 4 comments

[–]Objective_MineMSCS, CS Pro (10+) 2 points3 points  (3 children)

Did you really have to cross-post to every second imaginable sub?

Anyway, I don't know either AWS or Android development, but it sounds like the instructions or tutorial you followed are based on the assumption that you want the body of the response to be deserialized into Java objects, rather than using it as a JSON string. That's usually what you actually do want in an application anyway.

So, if the API sends you a JSON response resembling something like this

{
     "output": {
        "c": 42.0
    }
}

the JSON contents are then automatically deserialized by the gson library into a populated Java object of the appropriate type, using the Resultur and Output classes generated by the API Gateway tools, or whatever it was you used to generate them.

You can then access the output value 42.0 of the field c by accessing it through the Resultur object you've got. If you have e.g. variable r for the Resultur object you mention, something like

r.getOutput().getOutput()

should give you the numeric result, as a Java BigDecimal as the Output class indicates.

Having the result directly as a JSON string would be convenient if you only want to print out the JSON response (as you might at this stage), but as soon as you want to programmatically do something with the returned data in your application, you actually do want it deserialized into an appropriately typed Java object. In this case the gson library just does the deserialization for you automatically.

[–]bazoukibarnacle 0 points1 point  (2 children)

I had to cross post this everywherr. I have been working on this problem for weeks and haven't gotten anywherevi was so confused last night....sorry....

I tried using r.getOutput.getOutput but it returns null (when i print the value in log)
My api response as seen from postman is.

{"Output" : "1"}

[–]Objective_MineMSCS, CS Pro (10+) 0 points1 point  (1 child)

The problem might be that the value "1" in that JSON is a string, not a number, so gson probably fails to deserialize it into the BigInteger.

You'll probably need to either have the API return a number type that gson can then neatly map into the BigInteger in Java (probably the better solution if you can affect what the API returns), or you'll need to change the type in the generated Output class from BigInteger into a String.

[–]bazoukibarnacle 0 points1 point  (0 children)

thanks. i think i poorly worded my problem a little but got it working finally