After consulting this post: Post!
I set up the code my way, need to improve , but will solve, including pq manipulate data to Insert in Firebird.
Here is the code :
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
JObject obj = (JObject)JObject.Load(reader);
string jsonrpc = obj["jsonrpc"].ToString();
int id = Convert.ToInt32(obj["id"]);
JArray array = (JArray)obj["result"]["lista"];
var listaProps = typeof(Lista).GetProperties().ToList();
foreach (JObject item in array)
{
foreach (var props in listaProps)
{
try
{
switch (item[props.Name].Type)
{
case JTokenType.String:
item[props.Name] = item[props.Name].ToString().ToUpper();
break;
case JTokenType.Null:
item[props.Name] = "'NULL'";
break;
default:
break;
}
}
catch (Exception)
{
}
}
}
var pizzaJson = new JsonPizza();
pizzaJson.id = id;
pizzaJson.result = new Result();
pizzaJson.result.lista = array.ToObject<Lista[]>();
pizzaJson.result.qtd = array.Count();
pizzaJson.jsonrpc = jsonrpc;
return pizzaJson;
}
To Deserializeobject :
var obj = JsonConvert.DeserializeObject<JsonPizza>(json, new PizzaPagedListConverter(typeof(JsonPizza)));
The Class PizzaPagedListConverter
:
internal class PizzaPagedListConverter : JsonConverter
To leave all string values in UPPERCASE when Serialize :
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
JToken t = JToken.FromObject(value);
if (t.Type == JTokenType.String)
{
t = t.ToString().ToUpper();
t.WriteTo(writer);
}
}
You will have to create a customization pro serializer. He even treats the naming convention for the properties (the keys, in this case), but I don’t remember having any configuration to manipulate the values.
– Jéf Bueno
To customize the keys I already found, now I really do not find in doc something to make all values in uppercase.
– Bruno Ferreira