Splunk Search

How to include double quotes in Switch Case

Anantha123
Communicator

Hi All,

How can I do switch case for below values
{"XXX":["ABC"]} == ABC
{"XXX":[]} == NULL .

| eval Name=case(Name == "{"XXX":[]}", "NULL", Name == "{"XXX":["ABC"]}", "ABC" ) - This is not working.

Thanks in Advance.

Tags (1)
0 Karma
1 Solution

tscroggins
Influencer

Splunk uses C-style escape sequences in strings. Escape the inner quotation marks with a backslash:

| eval Name=case(Name == "{\"XXX\":[]}", "NULL", Name == "{\"XXX\":[\"ABC\"]}", "ABC" )

View solution in original post

0 Karma

tscroggins
Influencer

Splunk uses C-style escape sequences in strings. Escape the inner quotation marks with a backslash:

| eval Name=case(Name == "{\"XXX\":[]}", "NULL", Name == "{\"XXX\":[\"ABC\"]}", "ABC" )

0 Karma

Anantha123
Communicator

Thank you. It works.

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...