I want to parse json into an object, problem is I don't have the key names in the json, only the values. Is it possible to parse these values into an object?
Code example:
public class Test
{
public uint one;
public bool trueOrFalse;
public uint three;
}
private void ParseTest()
{
Test test = JsonConvert.DeserializeObject<Test>("[1, true, 3]");
}
Error I get using Newtonsoft.Json:
JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,true,3]) into type 'Test' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
Edit: What I want is to unfold the array onto an object's properties, in declaration order.
I work with a project where I get a lot of these value arrays and I cannot write a custom convert function for all of them. My first solution was a function that would insert the field names into the json before parsing, but this eventually broke when the json structure became more complicated (class in a class...).