0

Hi I am new to c# and I want to change a JSON Array into one single JSON Object. Can anyone help me out here?

Here is my JSON Array:

[ { "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" } }

2
  • Are you sure you posted correct examples? Your array consists of just one element. You can just extract the first element. Commented May 6, 2019 at 8:12
  • My bad. I havent thought about getting the first element Commented May 6, 2019 at 8:43

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Frankly, it is possible to convert array with multiple elements into an object. It probably puts some constraints onto both final objects and elements of array, but it is certanly possible, because array itself is an object in some sence.
My bad! I haven't thought of just getting the first element in my array

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.