Splunk Search

Convert Splunk results from spl to JSON before 8.2

D0do
Explorer

Hello everybody,

I'm using an spl query that extracts some values from a lookup and sends them to a web API via POST request (for this i'm using the WebTools add-on).

To send data formatted as reported in the api swagger, I'm using the Splunk command "tojson" to convert Spl query results to Json in my test instance.

Since the tojson command is really new (props to Splunk for adding this!) and was introduced from 8.2, is there a way to do the same in previous Splunk versions?

Splunk Query: |inputlookup l2d.csv |eventstats values(tp) as id | table id,code | tojson <...curl using raw field from tojson>

Json format expected and produced with tojson command: {"id":["id1","id2"],"code":"00001"} 

 

Thank you for the attention, have a nice day,

Labels (3)
0 Karma
1 Solution

shivanshu1593
Builder

Hello @D0do ,

I believe this is what you're looking for:

https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-INTO-JSON/m-p/288299

Thanks,

S

***If this helped, please accept it as a solution. It helps others to find the solution for similar issues quickly.***

 

Thank you,
Shiv
###If you found the answer helpful, kindly consider upvoting/accepting it as the answer as it helps other Splunkers find the solutions to similar issues###

View solution in original post

D0do
Explorer

Thanks @shivanshu1593, much appreciated

0 Karma

shivanshu1593
Builder

Hello @D0do ,

I believe this is what you're looking for:

https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-INTO-JSON/m-p/288299

Thanks,

S

***If this helped, please accept it as a solution. It helps others to find the solution for similar issues quickly.***

 

Thank you,
Shiv
###If you found the answer helpful, kindly consider upvoting/accepting it as the answer as it helps other Splunkers find the solutions to similar issues###
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...