1. Download our Official Android App: Forums for Android!

Apps How to code a basic json/rest protocol on android?

Discussion in 'Android Development' started by Yathushan, Mar 9, 2011.

  1. Yathushan

    Yathushan Well-Known Member
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    205
    Joined:
    Jan 3, 2010

    Jan 3, 2010
    205
    7
    36
    London
    Hey all,

    I was wondering whether anyone could direct me in the right direction to carry out a rest protocol using Gson?

    I have attempted it using a code snippet from:

    Android JSON Parsing with Gson Tutorial - Java Code Geeks.

    I tried to to alter the data in both search response & results. I tried to change the @SerializedName in the result class to name, id, status as shown in the response section of the test API documentation. I then tried to make similar changes in the search response section to method & format as shown in the parameter to call the API. However, nothing happens when i try to run it. The program just f/c's. I am not sure what to substitute in for the @SerializedName in the response class as well.
    I used the following site to try it out:

    API Documentation - Tube Updates - The API for London Underground / TFL Data

    I have tried both with no avail. Could someone help me please?
     

    Advertisement

  2. metric152

    metric152 Member
    Rank:
    None
    Points:
    16
    Posts:
    37
    Joined:
    Nov 10, 2009

    Nov 10, 2009
    37
    1
    16
    I struggled with parsing JSON responses for awhile. I ended up using Jackson for parsing. I haven't built an object to send out, but the library should handle it.

    I used the TreeModel method of parsing json. Worked great for me.
    JacksonInFiveMinutes - FasterXML Wiki
     

Share This Page

Loading...