Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7946959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:17:46+00:00 2026-06-04T01:17:46+00:00

i’m trying to deserialize a json string into a new list on C# using

  • 0

i’m trying to deserialize a json string into a new list on C# using json.net.

When i do a direct deserialization i get some attributes as null because i have different objects on my list.

So i want to create a “translator” for that task, building generic objects and setting the attributes of my objects.

this is my progress..

CitasProfesorWeb.JavaService.AgendaWSService service =
    new JavaService.AgendaWSService();
JsonTextReader reader;

private void cargaDatos()
{
    String lista = service.obtenerCitasNuevas(2);
    reader = new JsonTextReader(new StringReader(lista));

    while (reader.Read())
    {
        //here i want to read the attributes or objects
    }
}

i have tried using JsonConvert.PopulateObject(reader,cita) but i’m getting an error message saying that i have invalid parameters.

–Edit–

This is the string that i’m receiving :

[{"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"}]

This is my class:

public class Cita
    {
        Profesor profesor;

        public Profesor Profesor
        {
            get { return profesor; }
            set { profesor = value; }
        }

        Alumno alumno;

        public Alumno Alumno
        {
            get { return alumno; }
            set { alumno = value; }
        }

        DateTime inicioCita;

        public DateTime InicioCita
        {
            get { return inicioCita; }
            set { inicioCita = value; }
        }

        String asunto;

        public String Asunto
        {
            get { return asunto; }
            set { asunto = value; }
        }

        String lugar;

        public String Lugar
        {
            get { return lugar; }
            set { lugar = value; }
        }

        int status;

        public int Status
        {
            get { return status; }
            set { status = value; }
        }

        DateTime fechaSolicitud;

        public DateTime FechaSolicitud
        {
            get { return fechaSolicitud; }
            set { fechaSolicitud = value; }
        }


    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:17:47+00:00Added an answer on June 4, 2026 at 1:17 am

    I would use dynamic to parse your json string like below (without the need to declare cita,horario,profesor,alumno classes)

    dynamic dynObj = JsonConvert.DeserializeObject(json);
    
    foreach (var cita in dynObj)
    {
        Console.WriteLine("{0} {1} {2}",
            cita.horario.profesor.apellido,
            cita.alumno.nombre,
            cita.fechaSolicitud
            );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.