Kapp27 on Thu, 08 Nov 2012 20:10:14

Hi I'm very new to this, so I really hope there is somebody smart out there that will help me.

My JSON file looks like this (index3.json):

{"weeks": [{ "week": 1, "mothertext":"Det her er uge 1 mor", "babytext": "Det her er uge 1 baby" } ,{ "week": 2, "mothertext":"Det her er uge 2 mor", "babytext": "Det her er uge 2 baby" } ,{ "week": 3, "mothertext":"Det her er uge 3 mor", "babytext": "Det her er uge 3 baby" } ]}

I want to create an array in visual studio so its possible to insert the text from the different properties. I.e. week.mothertext[1] (or how it would look like) would deliver a string with "Det her er uge 2 mor" and so on.

This is my code which I must admit is losely constructed from code I have found on the web.

public InformationPage()

public class weeksArray
public weekProperties[] weeklist { get; set; }

public class weekProperties
public int week { get; set; }
public string mothertext { get; set; }
public string babytext { get; set; }

private void myButton1_Click(object sender, RoutedEventArgs e)

var client = new WebClient();

client.OpenReadCompleted +=
( s, eargs ) =>
var serializer = new DataContractJsonSerializer(typeof(weeksArray));
var dataArray = (weeksArray)serializer.ReadObject(eargs.Result);

foreach(var obj in dataArray.weeks)

//This sort of works but doesnt allow me to retrieve the indidual objects like the
//the text for week: 3 only.

textBoxWeek0.TextWriter = textBoxWeek0.Text + obj.week;

var uri = new Uri("http://...../index3.json");
client.OpenReadAsync( uri );


Kapp27 on Fri, 09 Nov 2012 09:52:07

Has been solved on another site:

Lisa Zhu on Mon, 12 Nov 2012 08:37:22

Hi Kapp27,

Thanks for your sharing the solution. This is helpful for other developers in the forum who have interests in this problem.

Have a nice day!