journal
all all entries rss SoML excited dreams runes YRUU ultimate KTRU skate sleepy nihongo
Rob is 20,118 days old today.
prev day next day printable version

Entries this day: JSON Soness_almost_permanent_resident artists_way lin

JSON

1:24pm JST Wednesday 16 February 2011 (day 14938)

Sweet as. From Software Passion: Android ... JSON .. GSON, I got a bit of JSON decoded.

Per Parsing JSON using GSON in Android, to add the GSON jar, right click when editing your project in Eclipse, and select

Properties -> Java Build Path -> Libraries -> Add External JARs

and point to gson-1.6.jar (where 1.6 indicates the version of GSON).

Because he doesn't quite spell it out, this is after editing my main .java file that was created by default when I created a new project.

package com.softwarepassion.jsonexample;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URI;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import com.google.gson.Gson;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class Twitter_JSON extends Activity {
    /** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        runJSONParser();
    }
    public InputStream getJSONData(String url){
        DefaultHttpClient httpClient = new DefaultHttpClient();
        URI uri;
        InputStream data = null;
        try {
            uri = new URI(url);
            HttpGet method = new HttpGet(uri);
            HttpResponse response = httpClient.execute(method);
            data = response.getEntity().getContent();
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        return data;
    }

    public void runJSONParser(){
        try{
        Log.i("MY INFO", "Json Parser started..");
        Gson gson = new Gson();
        Reader r = new InputStreamReader(getJSONData("http://search.twitter.com/trends.json"));
        Log.i("MY INFO", r.toString());
        Twitter_trends objs = gson.fromJson(r, Twitter_trends.class);
        Log.i("MY INFO", ""+objs.getTrends().size());
        for(TwitterTrend tr : objs.getTrends()){
            Log.i("TRENDS", tr.getName() + " - " + tr.getUrl());
        }
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }
}

4:24pm JST Wednesday 16 February 2011 (day 14938)

Grr. For some reason I can't get the more complicated version I need to work for work to work.

12:40am JST Thursday 17 February 2011 (day 14939)

While talking to Lin about what I was trying to do, I realized why I couldn't get it to work. I was neglecting the first part of the JSON input. Silly. At least it's basically easy to fix.

3:53am JST Thursday 17 February 2011 (day 14939)

yep; easy fix. Now I need to put the data onto the screen instead of the log file.

permalink

Soness almost permanent resident

3:36pm JST Wednesday 16 February 2011 (day 14938)

Soness went to the immigration office on Monday, with her old passport, so she couldn't get her permanent residence visa. We talked to one of the senior guys there and he said because I live in the same house, I can pick it up for her, if I bring my passport, alien card, Soness's passport, a copy of her alien card, the postcard that says she can get her visa, and a revenue stamp for 8000 yen.

I brought all that to the counter today, and the girl was like, "sorry; you have to be family or married."

I assured them that someone said it was okay, but didn't know his name. They were like, "yah why don't you talk to the guy at counter number five."

Turns out, because this is "the last visa" someone receives in Japan, they want to have a little chat with the recipient to make sure they respect Japan culture or something.

hmmph

I saw the guy who said it was okay, and was like, "hey remember me? remember Soness? etc etc," and he did, but they assured me it's still impossible.

gah.

permalink

artists way

6:25pm JST Wednesday 16 February 2011 (day 14938)

Where's Arwen? She's usually here by now.

8:15pm JST Wednesday 16 February 2011 (day 14938)

Ironically, after successfully overcoming on Soness's behalf the NO responses I got from them, she's arguing that I "didn't play the game correctly" by not asking Divy for the money I gave her at the beginning of the game.

ps: Arwen didn't come tonight.

permalink

lin

12:38am JST Thursday 17 February 2011 (day 14939)

Lin fell asleep in my arms for about 10 minutes tonight during our date. So nice.

I look forward to being able to go home with her.

permalink
prev day next day