February 14th, 2012 04:49 AM
#1
JSON Object Help
======== VERSION INFORMATION ========
.NET Framework: 4, Visual Studio 2010, C# 4
======== VERSION INFORMATION ========
Hey guys,
I am accessing the Facebook Graph API and I am in a spot of bother, I have just started C# so this is probably beyond my reach at the moment but here goes:
I am trying to read the "message" field only on a certain level of indentation when returning a status query via the API. For example, Facebooks sample query is the following:
Code:
{
"id": "10150224661566729",
"from": {
"name": "Facebook",
"category": "Product/service",
"id": "20531316728"
},
"message": "Tune in to Facebook Live today at 10 a.m. PDT to be part of a live announcement about new technology from Mark Zuckerberg, Facebook engineers and our industry partners: http://ow.ly/4vlzf",
"updated_time": "2011-04-07T16:26:25+0000",
"likes": {
"data": [
{
"id": "100000806299951",
"name": "Bagus Darmawan Akp"
},
{
"id": "100000423654842",
"name": "Subash Braxston"
},
{
"id": "100001474125704",
"name": "Faouzi Krifa"
},
{
"id": "100001224156043",
"name": "Kartaliçe Cemre Apaydin"
},
{
"id": "100003352140449",
"name": "Elno Elnino ExtremeRules"
},
{
"id": "100000401275963",
"name": "Faizal Ferryansyah"
},
{
"id": "100000244420203",
"name": "Justred Onecollor Jempollovers"
},
{
"id": "100002022067454",
"name": "Doyeks Prakoso"
},
{
"id": "100002873170863",
"name": "Fhajar Adi Perdana"
},
{
"id": "100002692873817",
"name": "Ricky RobBy"
},
{
"id": "100000693579088",
"name": "Ndox Insider's"
},
{
"id": "100002493085329",
"name": "Sidiq Setiaku Stsetia"
},
{
"id": "100002226010594",
"name": "Jempoler's Mania"
},
{
"id": "100002093872725",
"name": "Irfan Stia"
},
{
"id": "100000657703310",
"name": "Dhedhe Sii Slankers Potlot"
},
{
"id": "100001133233564",
"name": "ARdii Ntu Omps"
},
{
"id": "100002451736703",
"name": "Aksan Fals Cobain Proprietor"
},
{
"id": "100000440082202",
"name": "Budi Igor"
},
{
"id": "100001053741762",
"name": "Arians Geniuz"
},
{
"id": "100002607470936",
"name": "Pangeran Charly"
},
{
"id": "100000177333868",
"name": "'Kaka UBay'"
},
{
"id": "100001622466005",
"name": "Didit Ipang"
},
{
"id": "100002369568836",
"name": "Uchiha Effandawa Natzhuko"
},
{
"id": "288500021",
"name": "Darren Jones"
},
{
"id": "100000599240929",
"name": "KhaIrul Czen"
}
],
"paging": {
"next": "https://graph.facebook.com/10150224661566729/likes?method=GET&metadata=true&format=json&callback=___GraphExplorerAsyncCallback___&access_token=AAACEdEose0cBABZC625Qy4YBZBfFnveQ4vKWYq8DXEC1r0K3o9UcahlMJCjO3ka5JRiTZBRSnRJWw04i8icrKh4gRkzXozZCe1lHT9lmZBkhoOU0jBvKO&limit=25&offset=25&__after_id=100000599240929"
}
},
"comments": {
"data": [
{
"id": "10150224661566729_16455616",
"from": {
"name": "Abysheke Rajput",
"id": "100001452433100"
},
"message": "yo....yeahhhhhhhhhhhhhhhhh",
"created_time": "2011-04-07T16:26:44+0000",
"likes": 30
},
{
"id": "10150224661566729_16455618",
"from": {
"name": "Sophia Woodmansee",
"id": "100000321901766"
},
"message": "oh....joy.",
"created_time": "2011-04-07T16:26:47+0000",
"likes": 35
},
{
"id": "10150224661566729_16455620",
"from": {
"name": "Rizki Halomoan Siregar",
"id": "1534948126"
},
"message": "-pertamax?",
"created_time": "2011-04-07T16:26:51+0000",
"likes": 28
},
{
"id": "10150224661566729_16455623",
"from": {
"name": "Tasha Auman",
"id": "100000482355535"
},
"message": "Late much?",
"created_time": "2011-04-07T16:26:54+0000",
"likes": 32
},
{
"id": "10150224661566729_16455625",
"from": {
"name": "John Flores Tello",
"id": "100000955138783"
},
"message": "1",
"created_time": "2011-04-07T16:26:57+0000",
"likes": 32
},
{
"id": "10150224661566729_16455626",
"from": {
"name": "RidWan IrsYad",
"id": "1835871120"
},
"message": "ketigaxxx",
"created_time": "2011-04-07T16:27:00+0000",
"likes": 32
},
{
"id": "10150224661566729_16455630",
"from": {
"name": "Marcello Tacconi",
"id": "100001883460100"
},
"message": "yeaaahhhh",
"created_time": "2011-04-07T16:27:01+0000",
"likes": 31
},
{
"id": "10150224661566729_16455631",
"from": {
"name": "Justin Buck",
"id": "1206231776"
},
"message": "Well copied",
"created_time": "2011-04-07T16:27:01+0000",
"likes": 32
},
{
"id": "10150224661566729_16455629",
"from": {
"name": "Jonathan Jarp",
"id": "1540719174"
},
"message": "No thanks XD",
"created_time": "2011-04-07T16:27:01+0000",
"likes": 26
},
{
"id": "10150224661566729_16455633",
"from": {
"name": "Gregory Watts",
"id": "1550427775"
},
"message": "NO FIX UR website..how many times do we have to tell you man.....",
"created_time": "2011-04-07T16:27:02+0000",
"likes": 33
},
{
"id": "10150224661566729_16455636",
"from": {
"name": "Çağhan Köksal",
"id": "1144724651"
},
"message": "ok",
"created_time": "2011-04-07T16:27:06+0000",
"likes": 34
},
{
"id": "10150224661566729_16455637",
"from": {
"name": "Hendrik Groß",
"id": "100001556614564"
},
"message": ":D:DD",
"created_time": "2011-04-07T16:27:07+0000",
"likes": 32
},
{
"id": "10150224661566729_16455638",
"from": {
"name": "Shahid Nazir Bhat",
"id": "100001182320550"
},
"message": "welldone",
"created_time": "2011-04-07T16:27:07+0000",
"likes": 28
},
{
"id": "10150224661566729_16455639",
"from": {
"name": "Agni Sharman",
"id": "1075462631"
},
"message": "super appu....",
"created_time": "2011-04-07T16:27:12+0000",
"likes": 31
},
{
"id": "10150224661566729_16455640",
"from": {
"name": "Robin Law",
"id": "1475125891"
},
"message": "Nah - facebook is fine just the way it is",
"created_time": "2011-04-07T16:27:12+0000",
"likes": 38
},
{
"id": "10150224661566729_16455641",
"from": {
"name": "Will Spurling",
"id": "600096752"
},
"message": "Sex is good.",
"created_time": "2011-04-07T16:27:13+0000",
"likes": 35
},
{
"id": "10150224661566729_16455642",
"from": {
"name": "Mary Margaret Conn",
"id": "100001077711661"
},
"message": "OMG I change my message to the fb email and now I can't go into profile page please help",
"created_time": "2011-04-07T16:27:17+0000",
"likes": 31
},
{
"id": "10150224661566729_16455645",
"from": {
"name": "Carl Bob Dingel Smith",
"id": "614736572"
},
"message": "Bebo we love you",
"created_time": "2011-04-07T16:27:20+0000",
"likes": 30
},
{
"id": "10150224661566729_16455648",
"from": {
"name": "Mithun Ryder",
"id": "100000837616569"
},
"message": "sure",
"created_time": "2011-04-07T16:27:22+0000",
"likes": 31
},
{
"id": "10150224661566729_16455649",
"from": {
"name": "Jackson Whiting",
"id": "100001136730331"
},
"message": "Ted Nugent is god!!!!!!",
"created_time": "2011-04-07T16:27:23+0000",
"likes": 33
},
{
"id": "10150224661566729_16455653",
"from": {
"name": "Dustin Wallace",
"id": "1801827624"
},
"message": "Third!",
"created_time": "2011-04-07T16:27:23+0000",
"likes": 34
},
{
"id": "10150224661566729_16455651",
"from": {
"name": "Anna Hernita Disandi",
"id": "100001485083243"
},
"message": "hohoho",
"created_time": "2011-04-07T16:27:23+0000",
"likes": 31
},
{
"id": "10150224661566729_16455650",
"from": {
"name": "Akshay Kumble",
"id": "100000351233713"
},
"message": "-.-",
"created_time": "2011-04-07T16:27:23+0000",
"likes": 32
},
{
"id": "10150224661566729_16455655",
"from": {
"name": "Darnell Boyle",
"id": "100000562997980"
},
"message": "Any1 under here is gay ---------",
"created_time": "2011-04-07T16:27:24+0000",
"likes": 34
},
{
"id": "10150224661566729_16455654",
"from": {
"name": "Aj Azadpour",
"id": "100000064584309"
},
"message": "you guys are assholes. fix facebook now",
"created_time": "2011-04-07T16:27:24+0000",
"likes": 35
}
],
"paging": {
"next": "https://graph.facebook.com/10150224661566729/comments?method=GET&metadata=true&format=json&callback=___GraphExplorerAsyncCallback___&access_token=AAACEdEose0cBABZC625Qy4YBZBfFnveQ4vKWYq8DXEC1r0K3o9UcahlMJCjO3ka5JRiTZBRSnRJWw04i8icrKh4gRkzXozZCe1lHT9lmZBkhoOU0jBvKO&limit=25&offset=25&__after_id=10150224661566729_16455654"
}
},
"type": "status"
}
I only want items on the same level of indentation as this line here:
Code:
"message": "Tune in to Facebook Live today at 10 a.m. PDT to be part of a live announcement about new technology from Mark Zuckerberg, Facebook engineers and our industry partners: http://ow.ly/4vlzf",
My problem is that I have no way of handling this without splitting the string, and that is pointless because it would only serve identical queries.
So I guess what I am asking is:
How can I go about retrieving specific fields like "name", "id" etc... on a specific level of indentation?
Thanks for any help,
Fluidz
Last edited by Fluidz; February 14th, 2012 at 07:08 AM .
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks