首页 > 解决方案 > Updating JObject (Newtonsoft.Json.Linq.JContainer) in PowerShell

问题描述

I am trying to update a JObject in PowerShell but running into some issues.

Currently I have:

PS> $jObject.GetType()

IsPublic IsSerial Name                                     BaseType                                                                                                                                   
-------- -------- ----                                     --------                                                                                                                                   
True     False    JObject                                  Newtonsoft.Json.Linq.JContainer  

PS> $jObject


Type                       : Object
HasValues                  : True
First                      : {}
Last                       : {}
Count                      : 3
Parent                     : {"pollingIntervalInS": "3600" "observedCertificates": [
                               "<CertUri1>",
                               "<CertUri2>",
                               "<CertUri3>"
                             ] "requireInitialSync": true}
Root                       : {secretsManagementSettings}
Next                       : 
Previous                   : 
Path                       : secretsManagementSettings
LineNumber                 : 0
LinePosition               : 0
IsReadOnly                 : False
AllowNew                   : True
AllowEdit                  : True
AllowRemove                : True
SupportsChangeNotification : True
SupportsSearching          : False
SupportsSorting            : False
IsSorted                   : False
SortProperty               : 
SortDirection              : Ascending
IsFixedSize                : False
SyncRoot                   : System.Object
IsSynchronized             : False
Keys                       : {pollingIntervalInS, observedCertificates, requireInitialSync}

I am trying to updated the "observedCertificates" list with another entry. have tried converting to json, and also tried to work with the newtonsoft assembly to modify but without any results.

Any tips on how to proceed would be appreciated.

标签: powershelljson.net

解决方案


推荐阅读