1

I have no idea how to parse JSON in java(or anything else). I've seen some tutorials but I can't get it straight.

I am trying to get title="Fabiola Jean and Laurent Lundy commented on a photo that you're tagged". All I need is to know how to create a getTitle() method this is the JSON I want to parse:

Connection[data=[Notification[id=notif__161136848 metadata=null title=Fabiola Jean and Laurent Lundy commented on a photo that you're tagged in. type=null]] nextPageUrl=https://graph.facebook.com/811204509/notifications?fields =title&value=1&format=json&redirect=1&access_token=MY_TOKEN&__paging_token= notif__161136848 previousPageUrl=https://graph.facebook.com/811204509/notifications?fields=title &value=1&format=json&redirect=1&access_token=MY_TOKEN&limit=5000&since=1342109329& __paging_token=notif__161136848&__previous=1 next=true previous=true] 
2
  • 1
    Check gson Commented Jul 13, 2012 at 4:44
  • 3
    This doesn't look like a JSON string. Commented Jul 13, 2012 at 4:56

1 Answer 1

3

First, the code you put in your question is absolutely not valid JSON. I'm not quite sure what it is, and it does not appear to be easily parsable.

Assuming you are trying to parse actual JSON you almost certainly want to use a 3rd party library instead of writing the code using string manipulation functions.

Gson would be my first recommendation, and Jackson is another alternative you might want to look at.

Sign up to request clarification or add additional context in comments.

1 Comment

It's the JSon that is returned when I try to get my notification from Facebook using restFb. Thank you,I will take a look at GSON

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.