2016-12-29 32 views
0

如果json对象不包含引号,则一切正常。帮助请 例外:ServiceStack无法将json对象与字符串中的引号反序列化为字典<string,string>

{"ResponseStatus":{"ErrorCode":"SerializationException","Message":"Unable to bind to request 'CompanyList'","StackTrace":" в ServiceStack.Serialization.StringMapTypeDeserializer.PopulateFromMap(Object instance, IDictionary`2 keyValuePairs, List`1 ignoredWarningsOnPropertyNames)\r\n в ServiceStack.Host.RestPath.CreateRequest(String pathInfo, Dictionary`2 queryStringAndFormData, Object fromInstance)\r\n в ServiceStack.Host.RestHandler.CreateRequest(IRequest httpReq, IRestPath restPath, Dictionary`2 requestParams, Object requestDto)\r\n в ServiceStack.Host.RestHandler.CreateRequest(IRequest httpReq, IRestPath restPath)\r\n в ServiceStack.Host.RestHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)","Errors":[{"ErrorCode":"SerializationException","FieldName":"query","Message":"'{\"Unknown\":\"company \\\"Railways\\\"\"}' is an Invalid value for 'query'"}],"Meta":null}} 
+0

不包含引号的JSON不是有效的JSON。请更新您的答案,以显示完整的异常StackTrace和您用于反序列化的代码。 – mythz

回答

1

如果JSON对象不包含引号,那么它被视为JSV。 ServiceStack的默认格式是JSV而不是JSON。

使用

T JsonSerializer.DeserializeFromString<T>(string value); 

解析JSON字符串到所需的类型。

相关问题