Unexpected character encountered while parsing value: {. Path '', line 1, position 1. at...












0















I'm facing the following error message while trying to convert json string from a http response to a object:




Exception: Unexpected character encountered while parsing value: {.
Path '', line 1, position 1. at
Newtonsoft.Json.JsonTextReader.ReadStringValue
(Newtonsoft.Json.ReadType readType) [0x002d8] in
:0 at
Newtonsoft.Json.JsonTextReader.ReadAsString () [0x00000] in
:0 at
Newtonsoft.Json.JsonReader.ReadForType
(Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean
hasConverter) [0x000c2] in :0 at
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize
(Newtonsoft.Json.JsonReader reader, System.Type objectType,
System.Boolean checkAdditionalContent) [0x000db] in
:0 at
Newtonsoft.Json.JsonSerializer.DeserializeInternal
(Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054]
in :0 at
Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader
reader, System.Type objectType) [0x00000] in
:0 at
Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value,
System.Type type, Newtonsoft.Json.JsonSerializerSettings settings)
[0x0002d] in :0 at
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value,
Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <
d32db49e5e3440729da31845c03ddc3a>:0 at
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value)
[0x00000] in :0 at
JmJmApp.Helpers.API.DetalhesChamado (System.String
IdentificadorChamado) [0x0004b] in
C:Users..JmJmAppJmJmAppJmJmAppHelpersAPI.cs:262




Here is the code I am using:



        public static object DetalhesChamado(string IdentificadorChamado)
{
/* inicio da requisição para a api rest */
var client = new RestClient("https://api.tomticket.com/chamado/8....8d65/0e8963d....7bfe25612ae78");
var request = new RestRequest(Method.GET);

request.RequestFormat = DataFormat.Json;
//request.AddHeader("content-type", "application/json; charset=utf-8");


IRestResponse response = client.Execute(request);
var encoding = response.ContentEncoding;

if (response.ResponseStatus == ResponseStatus.Completed) // Verifica se foi possivel acessar o servidor
{
try
{
//byte encodedBytes = Encoding.UTF8.GetBytes(response.Content);

var string_json = JsonConvert.DeserializeObject<string>(response.Content);

var resposta = JsonConvert.DeserializeObject<ChamadoData>(string_json);


//var resposta = JsonConvert.DeserializeObject<ChamadoData>( string_json );

return resposta;
}
catch (Exception e)
{

return false; // Falha ao deserializar
}
}
else
{
return false; // Sem conexão a internet
}

}


Here is the response as show by Debug of Visual Studio:



{"erro":false,"data":{"idchamado":"0e8963dde6ff227c5917bfe25612ae78","protocolo":80,"titulo":"Veda\u00e7\u00e3o e desempenho- Garantia Vencida","mensagem":"Mensagem: Est\u00e1 vazando g\u00e1s no meu ap\nNome do Empreendimento :Copacabana\n Numero da Unidade :43","mimetype":"text\/plain","email_cliente":"teste@example.com","prioridade":1,"tempotrabalho":0,"tempoabertura":null,"data_criacao":"21\/11\/2018 10:32","deadline":null,"valoritemhora":0,"valoritemhoraextra":0,"valorfinal":0,"valorfinalextra":0,"valorfinalbruto":0,"nomecliente":"cliente teste","tipochamado":"Externo","avaliadoproblemaresolvido":null,"avaliadoatendimento":null,"avaliacaocomentario":null,"dataencerramento":null,"ultimasituacao":3,"dataultimasituacao":"21\/11\/2018 10:36","descsituacao":"Respondido pelo cliente, aguardando resposta","categoria":null,"departamento":"Suporte Usu\u00e1rio","atendente":null,"id_cliente":"teste@example.com","status":null,"dataultimostatus":null,"nomeorganizacao":null,"campospersonalizados":,"campospersonalizados_finalizados":,"anexos":,"historico":[{"origem":"C","mensagem":"Passado 72 horas e ainda n\u00e3o recebi retorno","mimetype":"text\/plain","atendente":null,"data_hora":"21\/11\/2018 10:36","hora_inicio":null,"hora_fim":null,"anexos":}],"historico_status":}}"


enter image description here
Here are the classes I am using as target.



public class Historico
{
public string origem { get; set; }
public string mensagem { get; set; }
public string mimetype { get; set; }
public object atendente { get; set; }
public string data_hora { get; set; }
public object hora_inicio { get; set; }
public object hora_fim { get; set; }
public IList<object> anexos { get; set; }
}

public class ChamadoData
{
public string idchamado { get; set; }
public int protocolo { get; set; }
public string titulo { get; set; }
public string mensagem { get; set; }
public string mimetype { get; set; }
public string email_cliente { get; set; }
public int prioridade { get; set; }
public int tempotrabalho { get; set; }
public object tempoabertura { get; set; }
public string data_criacao { get; set; }
public object deadline { get; set; }
public int valoritemhora { get; set; }
public int valoritemhoraextra { get; set; }
public int valorfinal { get; set; }
public int valorfinalextra { get; set; }
public int valorfinalbruto { get; set; }
public string nomecliente { get; set; }
public string tipochamado { get; set; }
public object avaliadoproblemaresolvido { get; set; }
public object avaliadoatendimento { get; set; }
public object avaliacaocomentario { get; set; }
public object dataencerramento { get; set; }
public int ultimasituacao { get; set; }
public string dataultimasituacao { get; set; }
public string descsituacao { get; set; }
public object categoria { get; set; }
public string departamento { get; set; }
public object atendente { get; set; }
public string id_cliente { get; set; }
public object status { get; set; }
public object dataultimostatus { get; set; }
public object nomeorganizacao { get; set; }
public IList<object> campospersonalizados { get; set; }
public IList<object> campospersonalizados_finalizados { get; set; }
public IList<object> anexos { get; set; }
public IList<Historico> historico { get; set; }
public IList<object> historico_status { get; set; }
}

public class Historico
{
public bool erro { get; set; }
public Data data { get; set; }
}


I've searched for a solution on Google but none worked for me.



Does anyone has any Idea how to solve this issue?










share|improve this question

























  • You are deserializing response.Content as a string, and then deserializing that string a second time as ChamadoData. Why? The JSON payload isn't a string literal containing embedded double-serialized JSON so the first deserialization looks completely unnecessary, and would seem to be the cause of your problem.

    – dbc
    Nov 21 '18 at 16:42













  • I tried with just the second deserialization line: <code>var resposta = JsonConvert.DeserializeObject<ChamadoData>(response.Content);</code> but now it's returning a null object.

    – Evandro Lacerda
    Nov 21 '18 at 17:10













  • can you show your ChamadoData class

    – Ryan Schlueter
    Nov 21 '18 at 18:04











  • At this moment I don't have access to project. Tomorrow at morning I will post ir here. Thanks!

    – Evandro Lacerda
    Nov 21 '18 at 18:16











  • Well I used the site jsonutils to produce the Class. I 'm going to reproduce the class and post here in a moment.

    – Evandro Lacerda
    Nov 21 '18 at 18:21
















0















I'm facing the following error message while trying to convert json string from a http response to a object:




Exception: Unexpected character encountered while parsing value: {.
Path '', line 1, position 1. at
Newtonsoft.Json.JsonTextReader.ReadStringValue
(Newtonsoft.Json.ReadType readType) [0x002d8] in
:0 at
Newtonsoft.Json.JsonTextReader.ReadAsString () [0x00000] in
:0 at
Newtonsoft.Json.JsonReader.ReadForType
(Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean
hasConverter) [0x000c2] in :0 at
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize
(Newtonsoft.Json.JsonReader reader, System.Type objectType,
System.Boolean checkAdditionalContent) [0x000db] in
:0 at
Newtonsoft.Json.JsonSerializer.DeserializeInternal
(Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054]
in :0 at
Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader
reader, System.Type objectType) [0x00000] in
:0 at
Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value,
System.Type type, Newtonsoft.Json.JsonSerializerSettings settings)
[0x0002d] in :0 at
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value,
Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <
d32db49e5e3440729da31845c03ddc3a>:0 at
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value)
[0x00000] in :0 at
JmJmApp.Helpers.API.DetalhesChamado (System.String
IdentificadorChamado) [0x0004b] in
C:Users..JmJmAppJmJmAppJmJmAppHelpersAPI.cs:262




Here is the code I am using:



        public static object DetalhesChamado(string IdentificadorChamado)
{
/* inicio da requisição para a api rest */
var client = new RestClient("https://api.tomticket.com/chamado/8....8d65/0e8963d....7bfe25612ae78");
var request = new RestRequest(Method.GET);

request.RequestFormat = DataFormat.Json;
//request.AddHeader("content-type", "application/json; charset=utf-8");


IRestResponse response = client.Execute(request);
var encoding = response.ContentEncoding;

if (response.ResponseStatus == ResponseStatus.Completed) // Verifica se foi possivel acessar o servidor
{
try
{
//byte encodedBytes = Encoding.UTF8.GetBytes(response.Content);

var string_json = JsonConvert.DeserializeObject<string>(response.Content);

var resposta = JsonConvert.DeserializeObject<ChamadoData>(string_json);


//var resposta = JsonConvert.DeserializeObject<ChamadoData>( string_json );

return resposta;
}
catch (Exception e)
{

return false; // Falha ao deserializar
}
}
else
{
return false; // Sem conexão a internet
}

}


Here is the response as show by Debug of Visual Studio:



{"erro":false,"data":{"idchamado":"0e8963dde6ff227c5917bfe25612ae78","protocolo":80,"titulo":"Veda\u00e7\u00e3o e desempenho- Garantia Vencida","mensagem":"Mensagem: Est\u00e1 vazando g\u00e1s no meu ap\nNome do Empreendimento :Copacabana\n Numero da Unidade :43","mimetype":"text\/plain","email_cliente":"teste@example.com","prioridade":1,"tempotrabalho":0,"tempoabertura":null,"data_criacao":"21\/11\/2018 10:32","deadline":null,"valoritemhora":0,"valoritemhoraextra":0,"valorfinal":0,"valorfinalextra":0,"valorfinalbruto":0,"nomecliente":"cliente teste","tipochamado":"Externo","avaliadoproblemaresolvido":null,"avaliadoatendimento":null,"avaliacaocomentario":null,"dataencerramento":null,"ultimasituacao":3,"dataultimasituacao":"21\/11\/2018 10:36","descsituacao":"Respondido pelo cliente, aguardando resposta","categoria":null,"departamento":"Suporte Usu\u00e1rio","atendente":null,"id_cliente":"teste@example.com","status":null,"dataultimostatus":null,"nomeorganizacao":null,"campospersonalizados":,"campospersonalizados_finalizados":,"anexos":,"historico":[{"origem":"C","mensagem":"Passado 72 horas e ainda n\u00e3o recebi retorno","mimetype":"text\/plain","atendente":null,"data_hora":"21\/11\/2018 10:36","hora_inicio":null,"hora_fim":null,"anexos":}],"historico_status":}}"


enter image description here
Here are the classes I am using as target.



public class Historico
{
public string origem { get; set; }
public string mensagem { get; set; }
public string mimetype { get; set; }
public object atendente { get; set; }
public string data_hora { get; set; }
public object hora_inicio { get; set; }
public object hora_fim { get; set; }
public IList<object> anexos { get; set; }
}

public class ChamadoData
{
public string idchamado { get; set; }
public int protocolo { get; set; }
public string titulo { get; set; }
public string mensagem { get; set; }
public string mimetype { get; set; }
public string email_cliente { get; set; }
public int prioridade { get; set; }
public int tempotrabalho { get; set; }
public object tempoabertura { get; set; }
public string data_criacao { get; set; }
public object deadline { get; set; }
public int valoritemhora { get; set; }
public int valoritemhoraextra { get; set; }
public int valorfinal { get; set; }
public int valorfinalextra { get; set; }
public int valorfinalbruto { get; set; }
public string nomecliente { get; set; }
public string tipochamado { get; set; }
public object avaliadoproblemaresolvido { get; set; }
public object avaliadoatendimento { get; set; }
public object avaliacaocomentario { get; set; }
public object dataencerramento { get; set; }
public int ultimasituacao { get; set; }
public string dataultimasituacao { get; set; }
public string descsituacao { get; set; }
public object categoria { get; set; }
public string departamento { get; set; }
public object atendente { get; set; }
public string id_cliente { get; set; }
public object status { get; set; }
public object dataultimostatus { get; set; }
public object nomeorganizacao { get; set; }
public IList<object> campospersonalizados { get; set; }
public IList<object> campospersonalizados_finalizados { get; set; }
public IList<object> anexos { get; set; }
public IList<Historico> historico { get; set; }
public IList<object> historico_status { get; set; }
}

public class Historico
{
public bool erro { get; set; }
public Data data { get; set; }
}


I've searched for a solution on Google but none worked for me.



Does anyone has any Idea how to solve this issue?










share|improve this question

























  • You are deserializing response.Content as a string, and then deserializing that string a second time as ChamadoData. Why? The JSON payload isn't a string literal containing embedded double-serialized JSON so the first deserialization looks completely unnecessary, and would seem to be the cause of your problem.

    – dbc
    Nov 21 '18 at 16:42













  • I tried with just the second deserialization line: <code>var resposta = JsonConvert.DeserializeObject<ChamadoData>(response.Content);</code> but now it's returning a null object.

    – Evandro Lacerda
    Nov 21 '18 at 17:10













  • can you show your ChamadoData class

    – Ryan Schlueter
    Nov 21 '18 at 18:04











  • At this moment I don't have access to project. Tomorrow at morning I will post ir here. Thanks!

    – Evandro Lacerda
    Nov 21 '18 at 18:16











  • Well I used the site jsonutils to produce the Class. I 'm going to reproduce the class and post here in a moment.

    – Evandro Lacerda
    Nov 21 '18 at 18:21














0












0








0








I'm facing the following error message while trying to convert json string from a http response to a object:




Exception: Unexpected character encountered while parsing value: {.
Path '', line 1, position 1. at
Newtonsoft.Json.JsonTextReader.ReadStringValue
(Newtonsoft.Json.ReadType readType) [0x002d8] in
:0 at
Newtonsoft.Json.JsonTextReader.ReadAsString () [0x00000] in
:0 at
Newtonsoft.Json.JsonReader.ReadForType
(Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean
hasConverter) [0x000c2] in :0 at
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize
(Newtonsoft.Json.JsonReader reader, System.Type objectType,
System.Boolean checkAdditionalContent) [0x000db] in
:0 at
Newtonsoft.Json.JsonSerializer.DeserializeInternal
(Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054]
in :0 at
Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader
reader, System.Type objectType) [0x00000] in
:0 at
Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value,
System.Type type, Newtonsoft.Json.JsonSerializerSettings settings)
[0x0002d] in :0 at
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value,
Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <
d32db49e5e3440729da31845c03ddc3a>:0 at
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value)
[0x00000] in :0 at
JmJmApp.Helpers.API.DetalhesChamado (System.String
IdentificadorChamado) [0x0004b] in
C:Users..JmJmAppJmJmAppJmJmAppHelpersAPI.cs:262




Here is the code I am using:



        public static object DetalhesChamado(string IdentificadorChamado)
{
/* inicio da requisição para a api rest */
var client = new RestClient("https://api.tomticket.com/chamado/8....8d65/0e8963d....7bfe25612ae78");
var request = new RestRequest(Method.GET);

request.RequestFormat = DataFormat.Json;
//request.AddHeader("content-type", "application/json; charset=utf-8");


IRestResponse response = client.Execute(request);
var encoding = response.ContentEncoding;

if (response.ResponseStatus == ResponseStatus.Completed) // Verifica se foi possivel acessar o servidor
{
try
{
//byte encodedBytes = Encoding.UTF8.GetBytes(response.Content);

var string_json = JsonConvert.DeserializeObject<string>(response.Content);

var resposta = JsonConvert.DeserializeObject<ChamadoData>(string_json);


//var resposta = JsonConvert.DeserializeObject<ChamadoData>( string_json );

return resposta;
}
catch (Exception e)
{

return false; // Falha ao deserializar
}
}
else
{
return false; // Sem conexão a internet
}

}


Here is the response as show by Debug of Visual Studio:



{"erro":false,"data":{"idchamado":"0e8963dde6ff227c5917bfe25612ae78","protocolo":80,"titulo":"Veda\u00e7\u00e3o e desempenho- Garantia Vencida","mensagem":"Mensagem: Est\u00e1 vazando g\u00e1s no meu ap\nNome do Empreendimento :Copacabana\n Numero da Unidade :43","mimetype":"text\/plain","email_cliente":"teste@example.com","prioridade":1,"tempotrabalho":0,"tempoabertura":null,"data_criacao":"21\/11\/2018 10:32","deadline":null,"valoritemhora":0,"valoritemhoraextra":0,"valorfinal":0,"valorfinalextra":0,"valorfinalbruto":0,"nomecliente":"cliente teste","tipochamado":"Externo","avaliadoproblemaresolvido":null,"avaliadoatendimento":null,"avaliacaocomentario":null,"dataencerramento":null,"ultimasituacao":3,"dataultimasituacao":"21\/11\/2018 10:36","descsituacao":"Respondido pelo cliente, aguardando resposta","categoria":null,"departamento":"Suporte Usu\u00e1rio","atendente":null,"id_cliente":"teste@example.com","status":null,"dataultimostatus":null,"nomeorganizacao":null,"campospersonalizados":,"campospersonalizados_finalizados":,"anexos":,"historico":[{"origem":"C","mensagem":"Passado 72 horas e ainda n\u00e3o recebi retorno","mimetype":"text\/plain","atendente":null,"data_hora":"21\/11\/2018 10:36","hora_inicio":null,"hora_fim":null,"anexos":}],"historico_status":}}"


enter image description here
Here are the classes I am using as target.



public class Historico
{
public string origem { get; set; }
public string mensagem { get; set; }
public string mimetype { get; set; }
public object atendente { get; set; }
public string data_hora { get; set; }
public object hora_inicio { get; set; }
public object hora_fim { get; set; }
public IList<object> anexos { get; set; }
}

public class ChamadoData
{
public string idchamado { get; set; }
public int protocolo { get; set; }
public string titulo { get; set; }
public string mensagem { get; set; }
public string mimetype { get; set; }
public string email_cliente { get; set; }
public int prioridade { get; set; }
public int tempotrabalho { get; set; }
public object tempoabertura { get; set; }
public string data_criacao { get; set; }
public object deadline { get; set; }
public int valoritemhora { get; set; }
public int valoritemhoraextra { get; set; }
public int valorfinal { get; set; }
public int valorfinalextra { get; set; }
public int valorfinalbruto { get; set; }
public string nomecliente { get; set; }
public string tipochamado { get; set; }
public object avaliadoproblemaresolvido { get; set; }
public object avaliadoatendimento { get; set; }
public object avaliacaocomentario { get; set; }
public object dataencerramento { get; set; }
public int ultimasituacao { get; set; }
public string dataultimasituacao { get; set; }
public string descsituacao { get; set; }
public object categoria { get; set; }
public string departamento { get; set; }
public object atendente { get; set; }
public string id_cliente { get; set; }
public object status { get; set; }
public object dataultimostatus { get; set; }
public object nomeorganizacao { get; set; }
public IList<object> campospersonalizados { get; set; }
public IList<object> campospersonalizados_finalizados { get; set; }
public IList<object> anexos { get; set; }
public IList<Historico> historico { get; set; }
public IList<object> historico_status { get; set; }
}

public class Historico
{
public bool erro { get; set; }
public Data data { get; set; }
}


I've searched for a solution on Google but none worked for me.



Does anyone has any Idea how to solve this issue?










share|improve this question
















I'm facing the following error message while trying to convert json string from a http response to a object:




Exception: Unexpected character encountered while parsing value: {.
Path '', line 1, position 1. at
Newtonsoft.Json.JsonTextReader.ReadStringValue
(Newtonsoft.Json.ReadType readType) [0x002d8] in
:0 at
Newtonsoft.Json.JsonTextReader.ReadAsString () [0x00000] in
:0 at
Newtonsoft.Json.JsonReader.ReadForType
(Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean
hasConverter) [0x000c2] in :0 at
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize
(Newtonsoft.Json.JsonReader reader, System.Type objectType,
System.Boolean checkAdditionalContent) [0x000db] in
:0 at
Newtonsoft.Json.JsonSerializer.DeserializeInternal
(Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054]
in :0 at
Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader
reader, System.Type objectType) [0x00000] in
:0 at
Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value,
System.Type type, Newtonsoft.Json.JsonSerializerSettings settings)
[0x0002d] in :0 at
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value,
Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <
d32db49e5e3440729da31845c03ddc3a>:0 at
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value)
[0x00000] in :0 at
JmJmApp.Helpers.API.DetalhesChamado (System.String
IdentificadorChamado) [0x0004b] in
C:Users..JmJmAppJmJmAppJmJmAppHelpersAPI.cs:262




Here is the code I am using:



        public static object DetalhesChamado(string IdentificadorChamado)
{
/* inicio da requisição para a api rest */
var client = new RestClient("https://api.tomticket.com/chamado/8....8d65/0e8963d....7bfe25612ae78");
var request = new RestRequest(Method.GET);

request.RequestFormat = DataFormat.Json;
//request.AddHeader("content-type", "application/json; charset=utf-8");


IRestResponse response = client.Execute(request);
var encoding = response.ContentEncoding;

if (response.ResponseStatus == ResponseStatus.Completed) // Verifica se foi possivel acessar o servidor
{
try
{
//byte encodedBytes = Encoding.UTF8.GetBytes(response.Content);

var string_json = JsonConvert.DeserializeObject<string>(response.Content);

var resposta = JsonConvert.DeserializeObject<ChamadoData>(string_json);


//var resposta = JsonConvert.DeserializeObject<ChamadoData>( string_json );

return resposta;
}
catch (Exception e)
{

return false; // Falha ao deserializar
}
}
else
{
return false; // Sem conexão a internet
}

}


Here is the response as show by Debug of Visual Studio:



{"erro":false,"data":{"idchamado":"0e8963dde6ff227c5917bfe25612ae78","protocolo":80,"titulo":"Veda\u00e7\u00e3o e desempenho- Garantia Vencida","mensagem":"Mensagem: Est\u00e1 vazando g\u00e1s no meu ap\nNome do Empreendimento :Copacabana\n Numero da Unidade :43","mimetype":"text\/plain","email_cliente":"teste@example.com","prioridade":1,"tempotrabalho":0,"tempoabertura":null,"data_criacao":"21\/11\/2018 10:32","deadline":null,"valoritemhora":0,"valoritemhoraextra":0,"valorfinal":0,"valorfinalextra":0,"valorfinalbruto":0,"nomecliente":"cliente teste","tipochamado":"Externo","avaliadoproblemaresolvido":null,"avaliadoatendimento":null,"avaliacaocomentario":null,"dataencerramento":null,"ultimasituacao":3,"dataultimasituacao":"21\/11\/2018 10:36","descsituacao":"Respondido pelo cliente, aguardando resposta","categoria":null,"departamento":"Suporte Usu\u00e1rio","atendente":null,"id_cliente":"teste@example.com","status":null,"dataultimostatus":null,"nomeorganizacao":null,"campospersonalizados":,"campospersonalizados_finalizados":,"anexos":,"historico":[{"origem":"C","mensagem":"Passado 72 horas e ainda n\u00e3o recebi retorno","mimetype":"text\/plain","atendente":null,"data_hora":"21\/11\/2018 10:36","hora_inicio":null,"hora_fim":null,"anexos":}],"historico_status":}}"


enter image description here
Here are the classes I am using as target.



public class Historico
{
public string origem { get; set; }
public string mensagem { get; set; }
public string mimetype { get; set; }
public object atendente { get; set; }
public string data_hora { get; set; }
public object hora_inicio { get; set; }
public object hora_fim { get; set; }
public IList<object> anexos { get; set; }
}

public class ChamadoData
{
public string idchamado { get; set; }
public int protocolo { get; set; }
public string titulo { get; set; }
public string mensagem { get; set; }
public string mimetype { get; set; }
public string email_cliente { get; set; }
public int prioridade { get; set; }
public int tempotrabalho { get; set; }
public object tempoabertura { get; set; }
public string data_criacao { get; set; }
public object deadline { get; set; }
public int valoritemhora { get; set; }
public int valoritemhoraextra { get; set; }
public int valorfinal { get; set; }
public int valorfinalextra { get; set; }
public int valorfinalbruto { get; set; }
public string nomecliente { get; set; }
public string tipochamado { get; set; }
public object avaliadoproblemaresolvido { get; set; }
public object avaliadoatendimento { get; set; }
public object avaliacaocomentario { get; set; }
public object dataencerramento { get; set; }
public int ultimasituacao { get; set; }
public string dataultimasituacao { get; set; }
public string descsituacao { get; set; }
public object categoria { get; set; }
public string departamento { get; set; }
public object atendente { get; set; }
public string id_cliente { get; set; }
public object status { get; set; }
public object dataultimostatus { get; set; }
public object nomeorganizacao { get; set; }
public IList<object> campospersonalizados { get; set; }
public IList<object> campospersonalizados_finalizados { get; set; }
public IList<object> anexos { get; set; }
public IList<Historico> historico { get; set; }
public IList<object> historico_status { get; set; }
}

public class Historico
{
public bool erro { get; set; }
public Data data { get; set; }
}


I've searched for a solution on Google but none worked for me.



Does anyone has any Idea how to solve this issue?







c# json json.net restsharp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 18:36







Evandro Lacerda

















asked Nov 21 '18 at 16:22









Evandro LacerdaEvandro Lacerda

1114




1114













  • You are deserializing response.Content as a string, and then deserializing that string a second time as ChamadoData. Why? The JSON payload isn't a string literal containing embedded double-serialized JSON so the first deserialization looks completely unnecessary, and would seem to be the cause of your problem.

    – dbc
    Nov 21 '18 at 16:42













  • I tried with just the second deserialization line: <code>var resposta = JsonConvert.DeserializeObject<ChamadoData>(response.Content);</code> but now it's returning a null object.

    – Evandro Lacerda
    Nov 21 '18 at 17:10













  • can you show your ChamadoData class

    – Ryan Schlueter
    Nov 21 '18 at 18:04











  • At this moment I don't have access to project. Tomorrow at morning I will post ir here. Thanks!

    – Evandro Lacerda
    Nov 21 '18 at 18:16











  • Well I used the site jsonutils to produce the Class. I 'm going to reproduce the class and post here in a moment.

    – Evandro Lacerda
    Nov 21 '18 at 18:21



















  • You are deserializing response.Content as a string, and then deserializing that string a second time as ChamadoData. Why? The JSON payload isn't a string literal containing embedded double-serialized JSON so the first deserialization looks completely unnecessary, and would seem to be the cause of your problem.

    – dbc
    Nov 21 '18 at 16:42













  • I tried with just the second deserialization line: <code>var resposta = JsonConvert.DeserializeObject<ChamadoData>(response.Content);</code> but now it's returning a null object.

    – Evandro Lacerda
    Nov 21 '18 at 17:10













  • can you show your ChamadoData class

    – Ryan Schlueter
    Nov 21 '18 at 18:04











  • At this moment I don't have access to project. Tomorrow at morning I will post ir here. Thanks!

    – Evandro Lacerda
    Nov 21 '18 at 18:16











  • Well I used the site jsonutils to produce the Class. I 'm going to reproduce the class and post here in a moment.

    – Evandro Lacerda
    Nov 21 '18 at 18:21

















You are deserializing response.Content as a string, and then deserializing that string a second time as ChamadoData. Why? The JSON payload isn't a string literal containing embedded double-serialized JSON so the first deserialization looks completely unnecessary, and would seem to be the cause of your problem.

– dbc
Nov 21 '18 at 16:42







You are deserializing response.Content as a string, and then deserializing that string a second time as ChamadoData. Why? The JSON payload isn't a string literal containing embedded double-serialized JSON so the first deserialization looks completely unnecessary, and would seem to be the cause of your problem.

– dbc
Nov 21 '18 at 16:42















I tried with just the second deserialization line: <code>var resposta = JsonConvert.DeserializeObject<ChamadoData>(response.Content);</code> but now it's returning a null object.

– Evandro Lacerda
Nov 21 '18 at 17:10







I tried with just the second deserialization line: <code>var resposta = JsonConvert.DeserializeObject<ChamadoData>(response.Content);</code> but now it's returning a null object.

– Evandro Lacerda
Nov 21 '18 at 17:10















can you show your ChamadoData class

– Ryan Schlueter
Nov 21 '18 at 18:04





can you show your ChamadoData class

– Ryan Schlueter
Nov 21 '18 at 18:04













At this moment I don't have access to project. Tomorrow at morning I will post ir here. Thanks!

– Evandro Lacerda
Nov 21 '18 at 18:16





At this moment I don't have access to project. Tomorrow at morning I will post ir here. Thanks!

– Evandro Lacerda
Nov 21 '18 at 18:16













Well I used the site jsonutils to produce the Class. I 'm going to reproduce the class and post here in a moment.

– Evandro Lacerda
Nov 21 '18 at 18:21





Well I used the site jsonutils to produce the Class. I 'm going to reproduce the class and post here in a moment.

– Evandro Lacerda
Nov 21 '18 at 18:21












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416404%2funexpected-character-encountered-while-parsing-value-path-line-1-positi%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416404%2funexpected-character-encountered-while-parsing-value-path-line-1-positi%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]