How to extract specific node in JSON Databank

Hi Team,

I have a requirement where i have to get the specific node in json object.

from the below example, How do i fetch the "Node_12345", any help would be appreciatable.

"Node_12345": {
"Key": "XXXXX",
"value": "YYYYY"
},

I have use xpath : root\node() --> this gives me complete xml. But i need to fetch this node alone.

Comments

  • OmarROmarR Posts: 176 admin

    Hey Uday,

    Do you want to capture the name of the node or the entire element? Try the following:

    Xpath: /root
    result: {"Node_12345":{"Key":"XXXXX","value":"YYYYY"}}

    Xpath: /root/Node_12345[1]/name()
    result: Node_12345

  • ParasofttoudayaParasofttoudaya Posts: 164
    edited October 2017

    Hi Omar,

    Problem here is i dont have the node value.

    without the node values, is it possible to get all the nodes present in that loop..
    configs{
    "Node_1": {
    "Key": "XXXXX",
    "value": "YYYYY"
    },
    "Node_2": {
    "Key": "XXXXX",
    "value": "YYYYY"
    },
    "Node_3": {
    "Key": "XXXXX",
    "value": "YYYYY"
    },
    "Node_4": {
    "Key": "XXXXX",
    "value": "YYYYY"
    }
    }

    expected result is like

    Node_1
    Node_2
    Node_3
    Node_4

  • OmarROmarR Posts: 176 admin

    Do they all have a partially similar name?
    If so, You may be able to use the "contains" function to retrieve all the node names that contain the shared word in their name.

  • ParasofttoudayaParasofttoudaya Posts: 164
    edited October 2017

    They have all different names..

    Basically it supposed to be retrieved database, there are 1000 number of response like that and we wanted to make only one call... When we make one call its difficult to use the writable data source

  • ParasofttoudayaParasofttoudaya Posts: 164

    Currently we can ignore of this question, I found another solution to loop thru the values.
    Passed the DB call output to writable data source and used regular xpath expression to retrieve the values.

    Thanks
    Udaya

Sign In or Register to comment.