简体   繁体   English

在C#中将JSON ARRAY转换为JSON对象

[英]JSON ARRAY to JSON Object in c#

Hi I am new to c# and I want to change a JSON Array into one single JSON Object. 嗨,我是c#的新手,我想将JSON数组更改为一个JSON对象。 Can anyone help me out here? 有人可以帮我从这里出去吗?

Here is my JSON Array: 这是我的JSON数组:

[ { "A": { "type": "string", "defaultValue": "autogenerated" }, "B": { "type": "string", "defaultValue": "autogenerated" }, "C": { "type": "dropdown", "dropDownItems": [ "true", "false" ], "defaultValue": "false" } } ]

And this is my expected output: { "A": { "type": "string", "defaultValue": "autogenerated" }, "B": { "type": "string", "defaultValue": "autogenerated" }, "C": { "type": "dropdown", "dropDownItems": [ "true", "false" ], "defaultValue": "false" } } 这是我的预期输出: { "A": { "type": "string", "defaultValue": "autogenerated" }, "B": { "type": "string", "defaultValue": "autogenerated" }, "C": { "type": "dropdown", "dropDownItems": [ "true", "false" ], "defaultValue": "false" } }

Logically it is impossible to convert an array with multiple elements to an object. 从逻辑上讲,不可能将具有多个元素的数组转换为对象。

However, if your example is your current scenario. 但是,如果您的示例是您当前的情况。 You may just take the first element in the array as an object. 您可以将数组中的第一个元素作为对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM