Can property of object in array be deleted using change node?

55 views
Skip to first unread message

mfeb

unread,
Jul 29, 2015, 5:46:28 PM7/29/15
to Node-RED
If so, what would be the path to the elements in the array?

Here's a snippet of the structure, and I'd like to remove the property "xml:lang": "en"

{
  "team": ":Cleveland_Cavaliers",
  "results": {
    "head": {
      "vars": [
        "Player",
        "Label"
      ]
    },
    "results": {
      "bindings": [
        {
          "Player": {
            "type": "uri",
            "value": "http://dbpedia.org/resource/Matthew_Dellavedova"
          },
          "Label": {
            "type": "literal",
            "xml:lang": "en",
            "value": "Matthew Dellavedova"
          }
       },

Nicholas O'Leary

unread,
Jul 30, 2015, 2:53:11 AM7/30/15
to Node-RED

No it can't, it isn't that sophisticated.
But we should look at how we could support that... something like jsonpath (equivalent to Xpath) would be needed.

Nick


--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave C-J

unread,
Jul 30, 2015, 4:46:43 AM7/30/15
to node...@googlegroups.com

mfeb

unread,
Jul 30, 2015, 2:46:46 PM7/30/15
to Node-RED, mfebl...@gmail.com
Well, I did go there next. I think I can get to the property using JSONPath but I couldn't figure out how that could be used to remove all instances of a given property.

Dave C-J

unread,
Jul 30, 2015, 3:04:32 PM7/30/15
to node...@googlegroups.com

Sounds like a custom function is required then...

mfeb

unread,
Jul 30, 2015, 4:57:13 PM7/30/15
to Node-RED, mfebl...@gmail.com
My next next step will be jsonpath-transform...if I can figure out how.

Thanks,

Mark


On Wednesday, July 29, 2015 at 5:46:28 PM UTC-4, mfeb wrote:

Julian Knight

unread,
Jul 31, 2015, 11:59:47 AM7/31/15
to Node-RED, mfebl...@gmail.com
I maybe being a bit slow but if you pass the json into a function node, the resulting msg variable will be just a javascript object so you can use delete on it to delete the element. If you are likely to have multiple elements which I think you are, all you need is a loop around the bit of the object you need to look in with an appropriate delete inside the loop.
Reply all
Reply to author
Forward
0 new messages