Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Friend

I'll get string in this format

C#
{"region": {"span": {"latitude_delta": 0.053973589999998239, "longitude_delta": 0.088729300000011335}, "center": {"latitude": 37.781268949999998, "longitude": -122.42869970000001}}, "total": 11600, "businesses": [{"is_claimed": true, "rating": 4.0, "mobile_url": "http://m.yelp.com/biz/brendas-french-soul-food-san-francisco", "rating_img_url": "http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png", "review_count": 3601, "name": "Brenda's French Soul Food", "snippet_image_url": "http://s3-media4.ak.yelpcdn.com/photo/_wuD-DWVLO9cs8Y5GoAg_Q/ms.jpg", "rating_img_url_small": "http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png", "url": "http://www.yelp.com/biz/brendas-french-soul-food-san-francisco", "phone": "4153458100", "snippet_text": "Came here last night and the wait time was 30 minutes. Not too bad, but busy for a Weds. eve of course. \n\nThe specials were amazing. I was concerned that...", "image_url": "http://s3-media1.ak.yelpcdn.com/bphoto/9fpwRXGc886-i63VHKvudA/ms.jpg", "categories": [["Cajun/Creole", "cajun"], ["Breakfast \u0026 Brunch", "breakfast_brunch"], ["Soul Food", "soulfood"]], "display_phone": "+1-415-345-8100", "rating_img_url_large": "http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png", "id": "brendas-french-soul-food-san-francisco", "is_closed": false, "location": {"cross_streets": "Turk St \u0026 Eddy St", "city": "San Francisco", "display_address": ["652 Polk St", "(b/t Turk St \u0026 Eddy St)", "Tenderloin", "San Francisco, CA 94102"], "geo_accuracy": 8, "neighborhoods": ["Tenderloin"], "postal_code": "94102", "country_code": "US", "address": ["652 Polk St"], "coordinate": {"latitude": 37.782891800000002, "longitude": -122.4189883}, "state_code": "CA"}}, {"is_claimed": true, "rating": 4.0, "mobile_url": "http://m.yelp.com/biz/the-chairman-truck-san-francisco", "rating_img_url": "http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png", "review_count": 1023, "name": "The Chairman Truck", "snippet_image_url": "http://s3-media4.ak.yelpcdn.com/photo/uEyByBXuKs_s99zt1tWebg/ms.jpg", "rating_img_url_small": "http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png", "url": "http://www.yelp.com/biz/the-chairman-truck-san-francisco", "phone": "4158138800", "snippet_text": "The steamed bun is really delicious. I love the soft texture, and the fact that it's smaller means I get to try more!\nI had the pork belly and the coca cola...", "image_url": "http://s3-media2.ak.yelpcdn.com/bphoto/h_jIunZo5UIsVzO2bgggRw/ms.jpg", "categories": [["Chinese", "chinese"], ["Food Trucks", "foodtrucks"]], "display_phone": "+1-415-813-8800", "rating_img_url_large": "http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png", "id": "the-chairman-truck-san-francisco", "is_closed": false, "location": {"cross_streets": "Willow St \u0026 Ellis St", "city": "San Francisco", "display_address": ["670 Larkin St", "(b/t Willow St \u0026 Ellis St)", "Tenderloin", "San Francisco, CA 94109"], "geo_accuracy": 8, "neighborhoods": ["Tenderloin"], "postal_code": "94109", "country_code": "US", "address": ["670 Larkin St"], "coordinate": {"latitude": 37.784046500000002, "longitude": -122.4176811}, "state_code": "CA"}}]} 


and want to convert this sting to datatable Or Array
not all field but some of like name,reviews,..etc

looking for your help

thanks
Posted
Updated 13-May-13 21:52pm
v7
Comments
tumbledDown2earth 10-May-13 3:43am    
If you are using Json.Net you can deserialize the string to JObject and then have to manually build a datatable

1 solution

Refer - How to convert json into datatable?[^].
Quote:
Assuming that your JSON string is a list of objects, each object will correspond to a row in the DataTable, viz:
C#
public DataTable DerializeDataTable()
{
    const string json = @"[{""Name"":""AAA"",""Age"":""22"",""Job"":""PPP""},"
                       + @"{""Name"":""BBB"",""Age"":""25"",""Job"":""QQQ""},"
                       + @"{""Name"":""CCC"",""Age"":""38"",""Job"":""RRR""}]";
    var table = JsonConvert.DeserializeObject<datatable>(json);
    return table;
}

This requires the Json.NET framework[^].
 
Share this answer
 
v2
Comments
Jimmy Darji 10-May-13 3:54am    
Thanks For Answer
the example that u given in your answer is working perfectly all right
but while i used my string it not working
The format might be the problem.
Can't you get the data in this format ?
Jimmy Darji 10-May-13 5:07am    
Thanks for your information
thank u very much
Hi Jimmy Darji,

Please accept this answer and up-vote, if it has helped you in any way.
This will help others to find the answer in one go and you will also be awarded with some points for this action...

Thanks,
Tadit
You rejected the solution... Is there any problem ? Or it is done by mistake ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900