Click here to Skip to main content
13,048,406 members (142,706 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello Friend

I'll get string in this format

{"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": "", "rating_img_url": "", "review_count": 3601, "name": "Brenda's French Soul Food", "snippet_image_url": "", "rating_img_url_small": "", "url": "", "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": "", "categories": [["Cajun/Creole", "cajun"], ["Breakfast \u0026 Brunch", "breakfast_brunch"], ["Soul Food", "soulfood"]], "display_phone": "+1-415-345-8100", "rating_img_url_large": "", "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": "", "rating_img_url": "", "review_count": 1023, "name": "The Chairman Truck", "snippet_image_url": "", "rating_img_url_small": "", "url": "", "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": "", "categories": [["Chinese", "chinese"], ["Food Trucks", "foodtrucks"]], "display_phone": "+1-415-813-8800", "rating_img_url_large": "", "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

Posted 9-May-13 21:27pm
Updated 13-May-13 21:52pm
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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Refer - How to convert json into datatable?[^].
Assuming that your JSON string is a list of objects, each object will correspond to a row in the DataTable, viz:
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[^].
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
Tadit Dash 10-May-13 4:29am
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
Tadit Dash 10-May-13 5:51am
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...

Tadit Dash 14-May-13 2:38am
You rejected the solution... Is there any problem ? Or it is done by mistake ?
Nirav Prabtani 29-Nov-13 0:59am
Hi tadit!!!, what kind of namespace i have to use for "JsonConvert"
Tadit Dash 29-Nov-13 1:37am
Hi Nirav, as I said in my answer, it requires Json.NET[^]. So, download and try to use that.
Nirav Prabtani 29-Nov-13 6:14am
Got it!!! ...thnx tadit.. :)
Tadit Dash 29-Nov-13 7:59am
Most welcome Nirav. :)
Tadit Dash 29-Nov-13 7:59am
Most welcome Nirav. :)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Aug 2015
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100