5 Replies - 1019 Views - Last Post: 10 November 2009 - 08:02 PM Rate Topic: -----

#1 Crazy_Learner  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 145
  • Joined: 25-July 09

Creating A Recursion

Posted 08 November 2009 - 02:51 PM

I Now that in general a recursion statement would like
private void Recursion(var one,var two)
{
   // do something
   Recursion(one,two);
}



however i am not sure how to apply to this format, i am wondering if anyone can help me make a recursion of it. The recursion i am trying to achieve is like the recursion that you would use for a treeview (IE -- infinite levels,each with infinite items)
string json = @"{   ""roots"": {	  ""bookmark_bar"": {		 ""children"": [ {			""children"": [ {			   ""date_added"": ""12880758517186875"",			   ""name"": ""Example URL"",			   ""type"": ""url"",			   ""url"": ""http://example.com""			}, {			   ""date_added"": ""12880290253039500"",			   ""name"": ""Another URL"",			   ""type"": ""url"",			   ""url"": ""http://example.org""			} ],		""date_added"": ""12880772259603750"",			""date_modified"": ""12880772452901500"",			""name"": ""Sample Folder"",			""type"": ""folder""		 }, {			""date_added"": ""12880823826333250"",			""name"": ""Json.NET"",			""type"": ""url"",			""url"": ""http://james.newtonking.com/pages/json-net.aspx""		 } ],		 ""date_added"": ""0"",		 ""date_modified"": ""12880823831234250"",		 ""name"": ""Bookmarks bar"",		 ""type"": ""folder""	  },	  ""other"": {		 ""children"": [  ],		 ""date_added"": ""0"",		 ""date_modified"": ""0"",		 ""name"": ""Other bookmarks"",		 ""type"": ""folder""	  }   },   ""version"": 1}";
		using (StringReader reader = new StringReader(json))
		using (JsonReader jsonReader = new JsonTextReader(reader))
		{
			JsonSerializer serializer = new JsonSerializer();
			var o = (JToken)serializer.Deserialize(jsonReader);
			try
			{
				for (int i = 0; i < countOfElements; i++)
				{
					var date_added = o["roots"]["bookmark_bar"]["children"][i]["name"];
					Console.WriteLine(date_added);
				}
			}
			catch (ArgumentOutOfRangeException arg)
			{
				Console.Write("\nDone");
				Console.Title = arg.Message;
			}
		}



Is This A Good Question/Topic? 0
  • +

Replies To: Creating A Recursion

#2 Crazy_Learner  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 145
  • Joined: 25-July 09

Re: Creating A Recursion

Posted 09 November 2009 - 04:55 PM

Since There Have Not Been Any Responses for a few days, i am going to discontinue this thread. Thank You for all who look at it
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Creating A Recursion

Posted 09 November 2009 - 05:01 PM

Well since you just posted this yesterday you cannot say

Quote

Since There Have Not Been Any Responses for a few days...


Show some patience my friend, I've got topics that are mor ethan a week old and not a single response, it happens. Sometimes you have to give it more than a day, especially when using something not many have used before (Such as this is the first time I've ever heard of JsonSerializer)
Was This Post Helpful? 0
  • +
  • -

#4 Grapevine  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 55
  • Joined: 26-October 09

Re: Creating A Recursion

Posted 09 November 2009 - 05:03 PM

srry i dnt know :(
Was This Post Helpful? 0
  • +
  • -

#5 Fuingurth  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 118
  • Joined: 13-August 09

Re: Creating A Recursion

Posted 10 November 2009 - 06:45 PM

dont worry, its no big deal really,
i do not know what JasonSerializer is, and have not been able to get anything on google for it but, your topic made me think of
this Google Joke.

...I hope that this may be helpful.... link
Was This Post Helpful? 0
  • +
  • -

#6 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1010
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: Creating A Recursion

Posted 10 November 2009 - 08:02 PM

http://james.newtonk...nSerializer.htm
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1