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!

Splunk MCP & Agentic AI: Machine Data Without Limits

  Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization ...

Finding Based Detections General Availability

Overview  We’ve come a long way, folks, but here in Enterprise Security 8.4 I’m happy to announce Finding ...

Get Your Hands Dirty (and Your Shoes Comfy): The Splunk Experience

Hands-On Learning and Technical Seminars  Sometimes, you just need to see the code. For those looking for a ...