Its been a day scratching my head & googling on how to convert json string to an object.
This is my json.
{
"statusCode": 200,
"data": {
"items": [
{
"id": 2623,
"JsonData": "{\"Number\":143,\"IsDeleted\":false,\"GapAnalysisChecked\":false,\"ShowGraphics\":true,\"Impact\":{\"Value\":\"DefaultNodeTitle_Impact\",\"Details\":null,\"DefaultValue\":\"DefaultNodeTitle_Impact\",\"Id\":\"0a507b25-cf0f-4ee3-8262-76b29adbda4e\"},\"Gap\":{\"Value\":\"DefaultNodeTitle_Gap\",\"Details\":null,\"DefaultValue\":\"DefaultNodeTitle_Gap\",\"Id\":\"cd411a47-a215-4dda-a8af-19686ad0d090\"}"}]
}
}
I am in need to convert JsonData to a single object.
var obj = JsonConvert.DeserializeObject(res.JsonData);
res.JsonData = obj; //this is giving error.- Cannot convert implicilty string to an object
Along with it, I have tried with number of permutatiation like DeserializeObject<Customer>() & all such things.
My desired output.
{
"statusCode": 200,
"data": {
"items": [
{
"id": 2623,
"JsonData": object
}
MY DTO
public class Res
{
public string StatusCode {get;set;}
public string JsonData {get; set;}
}
Any help/suggestion highly appreciated.
Thanks.
//this is giving error.isn't descriptive.. What error?res.JsonData = (object)obj;?{ "statusCode": 200, "data": { "items": [ { "id": 2623, "JsonData": object }]}this is valid JSON