07.01.2013 Views

David Defour - Université de Perpignan

David Defour - Université de Perpignan

David Defour - Université de Perpignan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

JSON-Based Loan Calculator<br />

Service<br />

• I<strong>de</strong>a<br />

– Make servlet for doing loan calculations<br />

• Input: JSON object with amount, period, and interest rate<br />

• Output: JSON object with inputs plus monthly payment and total<br />

payments<br />

• Approach<br />

– Server<br />

• Read parameter and pass to JSONObject constructor<br />

• Extract values with getDouble and getLong<br />

• Use same PaymentInfo class as in several previous examples<br />

• Turn PaymentInfo into JSON via JSONObject<br />

– Client (Android)<br />

• Build Map and turn into JSONObject, send to server<br />

• Read String, turn into JSONObject<br />

• Extract info with getString<br />

662<br />

jeudi 26 janvier 12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!