This is my Class for my ROOT object
public class Root
{
public List
}
public class Position
{
public string? SerialNumber { get; set; }
public int? position { get; set; }
public int? result { get; set; }
}
When I tried to add a hardcode values like below
public static List
{
new Root
{
Positions = new List
{
new Position
{
SerialNumber ="34543545",
position = 1,
result= 0,
},
new Position
{
SerialNumber ="34543545",
position = 2,
result= 0,
},
new Position
{
SerialNumber ="34543545",
position = 3,
result= 0,
}
}
}
};
but i need to add the values like below json format please help me how to add into list like below format
[{
"Positions": [
{
"SerialNumber ": "34543545"
},
{
"position": 1,
"result": 0
},
{
"position": 2,
"result": 0
},
{
"position": 3,
"result": 0
}
]
}]
PLz help
Amit MohantyPosted Jul 11, 2023, 7:40 AM
Check this:
DrtPosted Jul 11, 2023, 3:21 AM
Hi Jignesh,
Already I tired the above but am getting result like below but i want all the content under Positions
[
{
"SerialNumber ": "34543545",
"positions": [
{
"position": 1,
"result": 0
},
{
"position": 2,
"result": 1
},
{
"position": 3,
"result": 0
}
]
}
]
But i want the format like below
[{
"Positions": [
{
"panelSn": "34543545"
},
{
"position": 1,
"result": 0
},
{
"position": 2,
"result": 0
},
{
"position": 3,
"result": 0
}
]
}]
Jignesh KumarPosted Jul 11, 2023, 3:07 AM
Hello,
Please try this one,