0

Is it possible to de-serialize a complex json object as a string. I am having trouble solving an issue similar to what is described below:

public class Model
{
    public List<int> MyList { get; set; }
    public int MyInt { get; set; }
    public string MyString { get; set; }
    public string/object/variant MyProblem { get; set; }
}

Code used in the midddle-tier

model = JsonConvert.DeserializeObject<Model>(request.Model);

The problem is that MyProblem is actually a jagged array or it comes in multiple shapes by which I can't typify the structure to allow for de-serialization in a uniform manner. Is there a way that I can force JsonConvert to treat MyProblem as a string of Json instead of an object of Json?

Moment of clarity: It appears that if I define MyProblem as an object then the de-serialization will treat it as such and then MyProblem.ToString() will yield the json object as native string.

1 Answer 1

1

It appears that if I define MyProblem as an object then the de-serialization will treat it as such and then MyProblem.ToString() will yield the json object as native string.

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect, this was going to be a comment from me, glad you found something that is working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.