Splunk Search

How to remove [] in Json format data?

vikram1583
Explorer

I have a field properties.policies  in json format 

field value: [{"fieldname":"fieldvalue","fieldname":"fieldvalue","fieldname":"fieldvalue",[priview] "fieldname":"fieldvalue",[]}]

i want to remove first and last [] so that other fields can populate 

can some one send me the rex please ?

Thanks in advance

 

Labels (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval field=trim(field,"[]")
0 Karma

richgalloway
SplunkTrust
SplunkTrust

What have you tried so far? 

Parsing JSON using regular expressions can be challenging.  Have you tried the spath command?

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...