Freebase Output JSON result parsing in C# -
i've began using freebase api , i'm trying parse json result object c#. i'm getting fine output
field.
for example, using freebase's output
usage example:
{ "status": "200 ok", "result": [ { "mid": "/m/017n9", "id": "/en/blade_runner", "name": "blade runner", "notable": { "name": "future noir film", "id": "/m/0279xh5" }, "lang": "en", "score": 180.628250, "output": { "contributor": { "/film/film/cinematography": [ { "mid": "/m/0fxgcv", "name": "jordan cronenweth" } ], "/film/film/costume_design_by": [ { "mid": "/m/026ss4x", "name": "michael kaplan" }, { "mid": "/m/04g09v4", "name": "charles knode" } ], "/film/film/directed_by": [ { "mid": "/m/06chf", "name": "ridley scott" } ], "/film/film/edited_by": [ { "mid": "/m/02x5kd2", "name": "terry rawlings" }, { "mid": "/m/01xs0s0", "name": "marsha nakashima" } ], "/film/film/executive_produced_by": [ { "mid": "/m/061fnq", "name": "hampton fancher" }, { "mid": "/m/026_tq2", "name": "brian kelly" } ], "/film/film/film_art_direction_by": [ { "mid": "/m/03qlfwr", "name": "david snyder" } ], "/film/film/film_casting_director": [ { "mid": "/m/0b3x558", "name": "mike fenton" }, { "mid": "/m/07k6cmx", "name": "marci liroff" }, { "mid": "/m/0b3x55h", "name": "jane feinberg" } ], "/film/film/film_production_design_by": [ { "mid": "/m/05b5r87", "name": "lawrence g. paull" } ], "/film/film/film_set_decoration_by": [ { "mid": "/m/05b2jc_", "name": "linda descenna" }, { "mid": "/m/0bvb08x", "name": "leslie mccarthy-frankenheimer" }, { "mid": "/m/0b_3n1r", "name": "peg cummings" }, { "mid": "/m/0c1m0xc", "name": "thomas l. roysden" } ], "/film/film/music": [ { "mid": "/m/07zft", "name": "vangelis" } ], "/film/film/produced_by": [ { "mid": "/m/061fyk", "name": "michael deeley" }, { "mid": "/m/026vbvh", "name": "charles de lauzirika" } ], "/film/film/production_companies": [ { "mid": "/m/086k8", "name": "warner bros. entertainment" }, { "mid": "/m/0kqh5d", "name": "the ladd company" } ], "/film/film/story_by": [ { "mid": "/m/05qzv", "name": "philip k. dick" } ], "/film/film/written_by": [ { "mid": "/m/061fb6", "name": "david peoples" }, { "mid": "/m/061fnq", "name": "hampton fancher" } ], "/film/film_crew_gig/crewmember": [ { "mid": "/m/044hvf", "name": "douglas trumbull" }, { "mid": "/m/0bzjj60", "name": "gerry humphreys" }, { "mid": "/m/0bbfh2m", "name": "graham v. hartstone" }, { "mid": "/m/027prdy", "name": "marvin westmore" }, { "mid": "/m/0h7ndj8", "name": "bud alper" }, { "mid": "/m/0bnp6y1", "name": "peter pennell" } ], "/film/performance/actor": [ { "mid": "/m/0c0k1", "name": "harrison ford" }, { "mid": "/m/01xv77", "name": "daryl hannah" }, { "mid": "/m/016yr0", "name": "edward james olmos" }, { "mid": "/m/09byk", "name": "rutger hauer" }, { "mid": "/m/0380zg", "name": "sean young" }, { "mid": "/m/06lj1m", "name": "joanna cassidy" }, { "mid": "/m/06qgjh", "name": "james hong" }, { "mid": "/m/05njj5", "name": "brion james" }, { "mid": "/m/045931", "name": "m. emmet walsh" }, { "mid": "/m/05wqr1", "name": "william sanderson" }, { "mid": "/m/0czs9t", "name": "joe turkel" }, { "mid": "/m/03d2k31", "name": "morgan paull" }, { "mid": "/m/075jh5", "name": "hy pyke" }, { "mid": "/m/0gccl1x", "name": "john edward allen" }, { "mid": "/m/0gbzsdv", "name": "kevin thompson" } ] } } } ], "cursor": 1, "cost": 7, "hits": 530 }
i got these objects use c# javascriptdeserllizer:
public class notable { public string name { get; set; } public string id { get; set; } } public class filmfilmcinematography { public string mid { get; set; } public string name { get; set; } } public class filmfilmcostumedesignby { public string mid { get; set; } public string name { get; set; } } public class filmfilmdirectedby { public string mid { get; set; } public string name { get; set; } } public class filmfilmeditedby { public string mid { get; set; } public string name { get; set; } } public class filmfilmexecutiveproducedby { public string mid { get; set; } public string name { get; set; } } public class filmfilmfilmartdirectionby { public string mid { get; set; } public string name { get; set; } } public class filmfilmfilmcastingdirector { public string mid { get; set; } public string name { get; set; } } public class filmfilmfilmproductiondesignby { public string mid { get; set; } public string name { get; set; } } public class filmfilmfilmsetdecorationby { public string mid { get; set; } public string name { get; set; } } public class filmfilmmusic { public string mid { get; set; } public string name { get; set; } } public class filmfilmproducedby { public string mid { get; set; } public string name { get; set; } } public class filmfilmproductioncompany { public string mid { get; set; } public string name { get; set; } } public class filmfilmstoryby { public string mid { get; set; } public string name { get; set; } } public class filmfilmwrittenby { public string mid { get; set; } public string name { get; set; } } public class filmfilmcrewgigcrewmember { public string mid { get; set; } public string name { get; set; } } public class filmperformanceactor { public string mid { get; set; } public string name { get; set; } } public class musicrecordingcontributioncontributor { public string mid { get; set; } public string name { get; set; } } public class musicrecordingartist { public string mid { get; set; } public string name { get; set; } } public class contributor { public list<filmfilmcinematography> filmfilmcinematography { get; set; } public list<filmfilmcostumedesignby> filmfilmcostume_design_by { get; set; } public list<filmfilmdirectedby> filmfilmdirected_by { get; set; } public list<filmfilmeditedby> filmfilmedited_by { get; set; } public list<filmfilmexecutiveproducedby> filmfilmexecutive_produced_by { get; set; } public list<filmfilmfilmartdirectionby> filmfilmfilm_art_direction_by { get; set; } public list<filmfilmfilmcastingdirector> filmfilmfilm_casting_director { get; set; } public list<filmfilmfilmproductiondesignby> filmfilmfilm_production_design_by { get; set; } public list<filmfilmfilmsetdecorationby> filmfilmfilm_set_decoration_by { get; set; } public list<filmfilmmusic> filmfilmmusic { get; set; } public list<filmfilmproducedby> filmfilmproduced_by { get; set; } public list<filmfilmproductioncompany> filmfilmproduction_companies { get; set; } public list<filmfilmstoryby> filmfilmstory_by { get; set; } public list<filmfilmwrittenby> filmfilmwritten_by { get; set; } public list<filmfilmcrewgigcrewmember> filmfilm_crew_gigcrewmember { get; set; } public list<filmperformanceactor> filmperformanceactor { get; set; } public list<musicrecordingcontributioncontributor> musicrecording_contributioncontributor { get; set; } public list<musicrecordingartist> musicrecordingartist { get; set; } } public class output { public contributor contributor { get; set; } } public class result { public string mid { get; set; } public string id { get; set; } public string name { get; set; } public notable notable { get; set; } public string lang { get; set; } public double score { get; set; } public output output { get; set; } } public class rootobject { public string status { get; set; } public list<result> result { get; set; } public int cursor { get; set; } public int cost { get; set; } public int hits { get; set; } }
yet fields within output
null. how can fix issue?
so have been able solve using jsonpropety. should have declared on fields make sure correct values being converted them.
for example, this:
public list<filmfilmcinematography> filmfilmcinematography { get; set; }
... becomes:
[jsonpropety("/film/film/cinematography")] public list<filmfilmcinematography> filmfilmcinematography { get; set; }
Comments
Post a Comment