Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a generic class for converting JSON to objects (be sure to include <code>System.Web.Script.Serialization</code>)</p> <pre><code> public static T JsonToObject&lt;T&gt;(string JsonData) { // Deserialize the JSON into the object JavaScriptSerializer jss = new JavaScriptSerializer(); T rf = (T)jss.Deserialize(JsonData, typeof(T)); return rf; } </code></pre> <p>To convert an object back to JSON, use this general class</p> <pre><code> public static string ObjectToJson&lt;T&gt;(T rf) { // Serialize the object as JSON StringBuilder sb = new StringBuilder(); JavaScriptSerializer jss = new JavaScriptSerializer(); jss.Serialize(rf, sb); return sb.ToString(); } </code></pre> <p>As an example of usage, you would use</p> <pre><code> string json = @"[{""idCita"":6,""fechaSolicitud"":""2012/4/20"",""fechaCita"":""2012/4/19"",""horario"":{""idHorario"":1,""fechaInicio"":""2012/1/16"",""fechaHoy"":1337281297199,""fechaFin"":""2012/5/30"",""nombre"":""Enero-Mayo 2012"",""profesor"":{""idProfesor"":2, ""nombre"":""Guillermo"", ""apellido"":""Salazar"", ""nomUsuario"":""g.salazar"", ""email"":""g.salazar@itson.mx"", ""ubicacion"":""LV323"", ""descripcion"":""Profesor Interino""}},""alumno"":{""idAlumno"":1, ""nombre"":""Jhonatan"", ""apellido"":""Romero"", ""nomUsuario"":"" jromero"", ""email"":""jhonatanromgggggh"", ""carrera"":""LSIA"" },""asunto"":""asesorias"",""status"":""0"",""horaCita"":""10:0""}, {""idCita"":7,""fechaSolicitud"":""2012/4/20"",""fechaCita"":""2012/4/27"",""horario"":{""idHorario"":1,""fechaInicio"":""2012/1/16"",""fechaHoy"":1337281297199,""fechaFin"":""2012/5/30"",""nombre"":""Enero-Mayo 2012"",""profesor"":{""idProfesor"":2, ""nombre"":""Guillermo"", ""apellido"":""Salazar"", ""nomUsuario"":""g.salazar"", ""email"":""g.salazar@itson.mx"", ""ubicacion"":""LV323"", ""descripcion"":""Profesor Interino""}},""alumno"":{""idAlumno"":1, ""nombre"":""Jhonatan"", ""apellido"":""Romero"", ""nomUsuario"":"" jromero"", ""email"":""jhonatanromgggggh"", ""carrera"":""LSIA"" },""asunto"":""asesorias"",""status"":""0"",""horaCita"":""11:0""}, {""idCita"":11,""fechaSolicitud"":""2012/4/20"",""fechaCita"":""2012/4/20"",""horario"":{""idHorario"":1,""fechaInicio"":""2012/1/16"",""fechaHoy"":1337281297199,""fechaFin"":""2012/5/30"",""nombre"":""Enero-Mayo 2012"",""profesor"":{""idProfesor"":2, ""nombre"":""Guillermo"", ""apellido"":""Salazar"", ""nomUsuario"":""g.salazar"", ""email"":""g.salazar@itson.mx"", ""ubicacion"":""LV323"", ""descripcion"":""Profesor Interino""}},""alumno"":{""idAlumno"":1, ""nombre"":""Jhonatan"", ""apellido"":""Romero"", ""nomUsuario"":"" jromero"", ""email"":""jhonatanromgggggh"", ""carrera"":""LSIA"" },""asunto"":""asesorias"",""status"":""0"",""horaCita"":""17:0""}, {""idCita"":12,""fechaSolicitud"":""2012/4/27"",""fechaCita"":""2012/5/3"",""horario"":{""idHorario"":1,""fechaInicio"":""2012/1/16"",""fechaHoy"":1337281297199,""fechaFin"":""2012/5/30"",""nombre"":""Enero-Mayo 2012"",""profesor"":{""idProfesor"":2, ""nombre"":""Guillermo"", ""apellido"":""Salazar"", ""nomUsuario"":""g.salazar"", ""email"":""g.salazar@itson.mx"", ""ubicacion"":""LV323"", ""descripcion"":""Profesor Interino""}},""alumno"":{""idAlumno"":1, ""nombre"":""Jhonatan"", ""apellido"":""Romero"", ""nomUsuario"":"" jromero"", ""email"":""jhonatanromgggggh"", ""carrera"":""LSIA"" },""asunto"":""tesis"",""status"":""0"",""horaCita"":""12:0""}, {""idCita"":15,""fechaSolicitud"":""2012/5/11"",""fechaCita"":""2012/4/20"",""horario"":{""idHorario"":1,""fechaInicio"":""2012/1/16"",""fechaHoy"":1337281297200,""fechaFin"":""2012/5/30"",""nombre"":""Enero-Mayo 2012"",""profesor"":{""idProfesor"":2, ""nombre"":""Guillermo"", ""apellido"":""Salazar"", ""nomUsuario"":""g.salazar"", ""email"":""g.salazar@itson.mx"", ""ubicacion"":""LV323"", ""descripcion"":""Profesor Interino""}},""alumno"":{""idAlumno"":1, ""nombre"":""Jhonatan"", ""apellido"":""Romero"", ""nomUsuario"":"" jromero"", ""email"":""jhonatanromgggggh"", ""carrera"":""LSIA"" },""asunto"":""Tesis"",""status"":""0"",""horaCita"":""10:0""}]"; List&lt;Cita&gt; p = JsonToObject&lt;List&lt;Cita&gt;&gt;(json); </code></pre> <p><strong>EDIT:</strong> You specifically mentioned JSON.NET, so the above code may not help you if you want to keep with that. But, to parse all the attributes of a JSON string, you will need a class that matches the JSON response string. From there, you can set attributes of other objects as necessary.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload