I have following JSON format. I want to make images json object to json array. Means want to convert json object to json array.
This is my current JSON
"data": [
{
"id": "testid",
"variants": [
{
"name": "testname",
"description": "testdesc",
"images": {
"2T": [
{
"id": testid,
"product_id": "testid1"
}
]
}
}
],
}
]
I want to new JSON to look like this.
"data": [
{
"id": "testid",
"variants": [
{
"name": "testname",
"description": "testdesc",
"images": [ // here I want to convert to json array
"2T": [
{
"id": testid,
"product_id": "testid1"
}
]
]
}
],
}
]
2
Answers
As far I got your point:
You may want to convert the JSON object to a JSON array in C#, you can use the JArray class from the
Newtonsoft.Json.Linq
namespace. Here’s an example:This will output:
Json string you want is not valid , but you can try this code to get a valid json with image array
output