Splunk Search

Json field extract

priyangshupal
Engager

I have a json like this:

 

{
  "A": [
    {
      "B": [
        {
          "status": "2",
          "value": "1"
        },
        {
          "status": "1",
          "value": "2"
        },
        {
          "status": "3",
          "value": "4"
        },
        {
          "status": "5",
          "value": "8"
        }
      ]
    }
  ]
}

 

I want to extract the field  value.

I tried doing

 

spath input=field_name output=value path=A{0}.B{}.value

 

but it's not working

Pls help

Labels (2)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Works for me.

| makeresults 
| eval json="{
\"A\": [
{
\"B\": [
{
\"status\": \"2\",
\"value\": \"1\"
},
{
\"status\": \"1\",
\"value\": \"2\"
},
{
\"status\": \"3\",
\"value\": \"4\"
},
{
\"status\": \"5\",
\"value\": \"8\"
}
]
}
]
}"
| spath input=json path="A{}.B{}.value" output=vals

You forgot to put the path in quotes.

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...