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!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...