I would like to read the json file in ConvertFrom-Json in PSCustomObject, add the value, and output it as follows, but I don't know what command to execute.
"key:value" for foo2 and foo3 could be done with the following command:
However, I don't know how to add foo1 (object as json calls it).
If it is okay to use it as a PSCustomObject instead of a complete Json structure, I think it can be reproduced below.Does this meet the requirements?
If you need to save it as a Json structure, the middle array cannot be ConvertTo-Json, so you can either classify it separately and convert it with JsonQueryStringConverter, configure it in XML and convert it with JsonReaderWriterFactory, or incorporate a self-converting mechanism.
Isn't it like this?
can be achieved on the .
PowerShell doesn't care about data types.
The exact .NET
System.Object array allows you to mix any data type.In addition,
For example, using
can be written as .However, the
IDictionary as the object type of JSON.That's why
provides sufficient results.
© 2022 OneMinuteCode. All rights reserved.