Invoke method to remove a key-value pair in json gives error

There is probably silly but I am trying to remove a value in json. I have a json object and want to remove a line.
I am trying to use Invoke method,
TargetObject: blahjson
Method: Remove

param - in -string - “remove this”

I get “object does not have public instance” err

Hi @Nick101

Could you maybe provide a dummy sample of the JSON and a screenshot of how you configured your Invoke Method activity?

it’s not the json giving err, it is saying the jObject does not have a public instance method named Remove matching the parameter types, generic type arguments, …

if your JSON data is in string format, first convert it to a JObject using JObject.Parse(jsonString)


I gave it a try and it worked:

Some ideas:

  • make sure the Imports panel has the corresponding namespaces added:
    Newtonsoft.Json
    Newtonsoft.Json.Linq
    
  • make sure to update your System activity package

If these two simple fixes don’t work, it would help if you share your Studio and System package versions :slight_smile:

weird, I have all the requiremets


This will be a stretch, but…
I reproduced your issue by adding an extra space at the beginning of the Method Name:


It also breaks when you add it at the end.

2 Likes

Indeed that was the case!

1 Like

Stuck again, now I am trying to remove a key value from nested json
I can print it out using this write
outblah(“Towel”)(0)(“IsDirty”).ToString
I tried to make the target object as outblah(“Towel”)(0) and pass the params as (“IsDirty”)
I am getting this msg jtoken does not have a public instance named Remove
Tried all variations, like Target to be outblah and params to be towel as string and IsDirty as Jobject, still get err

Convert the JToken to JObject
towelObj = CType(outblah(“Towel”)(0), JObject)
outblah(“Towel”)(0) = towelObj.Property(“IsDirty”).Remove()

Thanks, that was the solution

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.