Download the library from http://james.newtonking.com/json

Add Newtonsoft.Json.dll to your main project directory.

Right click your project > Properties > Common Properties > Framework & References > Add new reference

Select the Browse tab and select the Newtonsoft.Json.dll file

Convert Json File To Class


using namespace Newtonsoft::Json

	//----- CLASSES FOR THE JSON DESERIALIZATION -----
	public ref class Json_global_channels
	{
		public: int channel_id;
		public: String ^channel_name;
	};
	public ref class Json_user_results					//For each sub group of json data create a new class and include it in the parent class
	{
		public: String ^valid_request;
		public: String ^password_key;
	};
	public ref class JsonRootObject
	{
		public: Json_user_results ^user_results;		//Name the object to match the name in json, in this case "user_results"
		public: array<Json_global_channels^> ^global_channels;			//Use an array (or List) for repeating json data
	};

	//UserJsonData has the json in it
	//Deserialize it:
	JsonRootObject ^MyJsonData1 = Newtonsoft::Json::JsonConvert::DeserializeObject<JsonRootObject^>(UserJsonData);

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.