Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting array element #94

Open
crow-ua opened this issue Sep 12, 2019 · 1 comment
Open

Deleting array element #94

crow-ua opened this issue Sep 12, 2019 · 1 comment

Comments

@crow-ua
Copy link

crow-ua commented Sep 12, 2019

I have an array in json:
"elements": [ "1", "2", "3", "4" ]
I want to delete the last one:
"elements/#[3]": ""
i get an error:

Transformation found: elements/#[3]: 
Transforming file C:\BuildAgent\_work\16\s\manifest\manifest.json

##[error]System.Management.Automation.MethodInvocationException: Exception calling "Transform" with "4" argument(s): "Object reference not set to an instance of an object." ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at MagicChunks.Helpers.JsonExtensions.GetChildProperty(JContainer source, String name)
   at MagicChunks.Documents.JsonDocument.UpdateTargetElement(JObject current, String targetElementName, String value)
   at MagicChunks.Documents.JsonDocument.ReplaceKey(String[] path, String value)
   at MagicChunks.Core.Transformer.Transform(IDocument source, TransformationCollection transformations)
   at MagicChunks.Core.Transformer.Transform(String source, TransformationCollection transformations)
   at MagicChunks.TransformTask.Transform(String type, String sourcePath, String targetPath, TransformationCollection transformation)
   at CallSite.Target(Closure , CallSite , Type , Object , Object , Object , Object )
   --- End of inner exception stack trace ---
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

I've also tried "#elements/[3]": "", fails too.

@NekidMugh
Copy link

Were you ever able to figure this out? I am encountering the same thing where I need to be able to change/delete a value in an single value array like yours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants