안녕하세요 Sql Server
에 Json
응답을로드하려고합니다. 그러나 Json
은 string
또는 object
일 수 있습니다. 여기 때때로 JSON 문자열을 역 직렬화 할 때 때때로 C#
{
"result": [
{
"upon_approval": "proceed",
"location": {
"link": "https://satellite.service-now.com/api/now/table/cmn_location/4a2cf91b13f2de00322dd4a76144b090",
"value": "4a2cf91b13f2de00322dd4a76144b090"
}}]}
는 그것이
object
{
"result": [
{
"upon_approval": "proceed",
"location": ""}]}
그리고 내 C# 클래스 인 경우의 예
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace incident
{
public class Location
{
public string link { get; set; }
public string value { get; set; }
}
public class Result
{
public Location location { get; set; }
}
public class RootObject
{
public List<Result> result { get; set; }
}
}
같이이다 : 여기
그것이
string
때 예입니다
Newtonsoft.Json
을 사용하고 있습니다. 이 작업을 수행하는 쉬운 방법이 있습니까? 난 정말이 문제를 이해하지 못하는
var location = new Location
{
Link = _request.Location?.Link,
Value = _request.Location?.Value
}
코드에는 아무런 문제가 없습니다. 'Result.Location'는'JSON'에 빈 문자열이 있으면 null이됩니다. deserialization에는 아무런 문제가 없습니다. 귀하의 질문은 무엇인가? – niksofteng
JavaScript를 디버깅하는 동안 C#의이 단계에서 'System.String'유형의 객체를 'incident.Location'을 입력 할 수 없습니다.이 오류가 발생합니다. ser = new JavaScriptSerializer(); ser.MaxJsonLength = 2147483647; RootObject ro = ser.Deserialize (responseValue); –
JavaScript를 디버깅하는 동안 C#의이 단계에서 'System.String'유형의 객체를 'incident.Location'을 입력 할 수 없습니다.이 오류가 발생합니다. ser = new JavaScriptSerializer(); ser.MaxJsonLength = 2147483647; RootObject ro = ser.Deserialize (responseValue); think2cecode1ce –