我有以下组可变JSON数据的其中第一行是元素名称和其他行的列表中表示元件的值的列表:变换嵌套JSON阵列成JSON对象的数组
[
[
"category",
"author",
"title",
"price"
],
[
"reference",
"Nigel Rees",
"Sayings of the Century",
"8.95"
],
[
"fiction",
"Evelyn Waugh",
"Sword of Honour",
"12.99"
],
[
"fiction",
"Herman Melville",
"Moby Dick",
"8.99"
],
[
"fiction",
"J. R. R. Tolkien",
"The Lord of the Rings",
"22.99"
]
]
我想从数据构建以下类型的JSON对象:
{
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
]
}
如何建立这应该是等同于我上面的JSON对象。我没有看到任何直接支持使用JSON.NET API来做到这一点。 任何帮助,不胜感激。
这看起来更像是某种CSV数据。 – Jerodev
请分享您尝试过的内容。这不是一个代码服务网站。迭代每一行,将其解析为相应的对象,添加到结果集合,然后转换为JSON。请参阅[如何提问](https://stackoverflow.com/help/how-to-ask),了解如何发布一个好问题 –