JamesNK / Newtonsoft.Json

Json.NET is a popular high-performance JSON framework for .NET
https://www.newtonsoft.com/json
MIT License
10.76k stars 3.25k forks source link

Help with exception when deserializing this JSON #95

Closed cortizqgithub closed 11 years ago

cortizqgithub commented 11 years ago

I am trying to parse this JSON

{"servicios":[{"inicio":"17\/06\/2013","salaForo":"","ptos":[{"nombre":"Teatro Metropolitano Jos\u00e9 Gutierrez G\u00f3mez","id":524,"direccion":"Calle\u00a041 Nro. 57-30","funcs":[{"hora":"20:00","dia":1}],"calif":4,"califres":3,"long":-75.576737523079,"lat":6.241350978501}],"img":"http:\/\/planepoly.com\/PlanepolyImgWeb\/Get?id=311&res=HR&tipo=600","fin":"17\/06\/2013","estr":0,"urlVideo":"","urlWww":"","url":"http:\/\/www.planepoly.com\/Accion?Servicio=311","id":311,"nombre":"Middlesex","genero":"Sin Clasificar","sinopsis":"Hora: 8:00 p.m.\nLugar: Teatro Metropolitano\nDescuento con Intelecto: 20 por ciento para 150 boletas disponibles. El descuento no incluye en Ticket Service\nInversi\u00f3n: 60.000 - 40.000 pesos.\nVenta de boleter\u00eda: Taquilla del Teatro Metropolitano y Tu Boleta.\nInformes: 232 28 58 - 232 45 97","tipo":209,"calif":0,"califres":0}, {"inicio":"07\/06\/2013","salaForo":"","ptos":[{"nombre":"Teatro Universidad de Medell\u00edn","id":530,"direccion":"Carrera 87 Nro. 30 - 65","funcs":[{"hora":"20:00","dia":5}],"calif":0,"califres":0,"long":-75.610582,"lat":6.232728}],"img":"http:\/\/planepoly.com\/PlanepolyImgWeb\/Get?id=254&res=HR&tipo=600","fin":"07\/06\/2013","estr":0,"urlVideo":"","urlWww":"","url":"http:\/\/www.planepoly.com\/Accion?Servicio=254","id":254,"nombre":"Tap Factory","genero":"Danza","sinopsis":"Hora: 8:00pm\nLugar: Teatro Universidad de Medell\u00edn\nInversi\u00f3n: $170,000, $150.000, $130,000 y $82,000.\nVenta de boleter\u00eda: taquilla Del Teatro Universidad de Medell\u00edn. \nInformes: 340 52 02.","tipo":209,"calif":0,"califres":0}, {"inicio":"06\/06\/2013","salaForo":"","ptos":[{"nombre":"El Teatrico","id":1044,"direccion":"Avenida Nutibara Transversal 39B #C2 -46","funcs":[{"hora":"20:00","dia":4}, {"hora":"20:00","dia":5}, {"hora":"20:00","dia":6}],"calif":4.67,"califres":3,"long":-75.59078,"lat":6.2432437}],"img":"http:\/\/planepoly.com\/PlanepolyImgWeb\/Get?id=305&res=HR&tipo=600","fin":"29\/06\/2013","estr":0,"urlVideo":"","urlWww":"","url":"http:\/\/www.planepoly.com\/Accion?Servicio=305","id":305,"nombre":"Humor Inmarcesible","genero":"Teatro","sinopsis":"\u00a1Un j\u00fabilo inmortal! Humor colombiano, m\u00e1s colombiano que tirar piscina en calzoncillos. Reservas: 411 8878. ","tipo":209,"calif":0,"califres":0}]}

I use var ev2 = JsonConvert.DeserializeObject(oneService); Response.Write(ev2.ToString());

Following are my object definition. // Event.cs using System; using System.Collections.Generic; using System.Web;

namespace ElColombiano.Service.Domain { public class Event { public List servicios { get; set; } } }

// ServiceItem using System; using System.Collections.Generic;

namespace ElColombiano.Service.Domain { public class ServiceItem { public String inicio { get; set; } public String salaForo { get; set; } public List ptos { get; set; } public String img { get; set; } public String fin { get; set; } public int estr { get; set; } public String urlVideo { get; set; } public String urlWww { get; set; } public String url { get; set; } public int id { get; set; } public String nombre { get; set; } public String genero { get; set; } public String sinopsis { get; set; } public int tipo { get; set; } public int calif { get; set; } public int califres { get; set; } } }

// LocationItem using System; using System.Collections.Generic;

namespace ElColombiano.Service.Domain { public class LocationItem { public String nombre { get; set; } public int id { get; set; } public String direccion { get; set; } public List funcs { get; set; } public int calif { get; set; } public int califres { get; set; } public float @long { get; set; } public float lat { get; set; } } }

// ShowItem using System;

namespace ElColombiano.Service.Domain { public class ShowItem { public String hora { get; set; } public int dia { get; set; } } }

JamesNK commented 11 years ago

Not a bug.

cortizqgithub commented 11 years ago

Thank you very much. But tell me. How did you get to the conclusion it is not a bug. Have you tried it? BTW, I am using the latest version. I was not submitting a bug. I was looking for help and a solid explanation because I don't know where to ask this by the way. Do you have some channel regarding this.

The Exception has to do with a Date formatting. Please have a run out of it, please, that's why I supplied the classes for mapping.

jonnii commented 11 years ago

ask on stackoverflow.

cortizqgithub commented 11 years ago

No problem, good hint jonnii. I just had a problem with my class mapping in C#. I used http://json2csharp.com and it all worked.

Ticked closed on my part.