这是我的自定义json转换器的一部分:
public class ExpandoConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return typeof(Expando).IsAssignableFrom(objectType);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null)
return null;
/// How can I get all json string from reader at this point like that:
/// string js= reader.ReadStringToEnd();
我不想获得所有序列化字符串,我需要转换器定位数据。
例如:
{.......................的 {"标识":3,"名称" :" MyExpando1"} }
答案 0 :(得分:0)
我管理的是使用JObject并将读者加载到JObject中,如下所示:
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
JObject jObject = JObject.Load(reader);
var dictionary = serializer.Deserialize<Dictionary<string, object>>(jObject);
}