Issue while usin 'JQ' Transformer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Issue while usin 'JQ' Transformer

L1 Bithead

Hello,

I would like to use 'jq' Transformer as designed in a custom "Mapper", but it constantly says to me that error message, whatever I am testing :
===> "Result: Failed to execute jq. Error: the JSON object must be str, bytes or bytearray, not dict"

Event though I tried barely everything in order to be able to test it, as you would be able to see it on enclosed screenshot, and as well on the simplest example here : https://jqplay.org/s/JTzcQNL1ui2

 

I tried .category,  ."category",  .{"category"},  .["category"],  [.category] and all variations, with the table as well or with .id,  ."id", .'id'... etc...etc...etc...


Many thanks in advance for your reply and Best Regards,
Thomas Nicolas

1 accepted solution

Accepted Solutions

Not with that jq transformer, that error seems like it wants the JSON as a string instead of a dictionary object. DT seems to be able to handle the JSON object without using stringify though.

View solution in original post

5 REPLIES 5

L4 Transporter

Hi @NicolasTHOMAS ,

 

Can I ask why you need JQ? If you click the Choose data path next to the field and click category the path will be automatically added and it will be valid for all JSON input for that specific mapper. If you explain what you are trying to achieve I can try to help further. Please see the below screenshot.

gyldz_0-1689674887177.png

 

 

Hello,

 

I would like to use JQ as we are fetching different incidents, with different fields to map, and I would like to do a dynamic mapping of @odata.comments[] tables our @odata.evidence[] (sometimes several evidences table, @odata.evidence[0], @odata.evidence[1], @odata.evidence[2])

 

Regards,
Thomas Nicolas

That error looks like it wants you to use the stringify operator prior to using the jq operator. I wasn't able to test since I don't have that jq transformer in my instance. I was able to use the DT transformer to parse out that category.
Screenshot 2023-07-18 at 10.26.59 AM.png

Instead of using DT or jq or another transformer though, I would try to use classifiers and mappers to map the data as needed. You can classify the data into different incident types with a classifier. Once you have the different incident types, you can then use an incoming mapper to map the fields per incident type. Below you can see where I map the field Alert Category based on 2 different inputs depending on which incident type is created by the classifier.

Screenshot 2023-07-18 at 10.32.50 AM.pngScreenshot 2023-07-18 at 10.32.37 AM.png

Ok, so you think it is not possible to parse a JSON array or a JSON Object ?

Not with that jq transformer, that error seems like it wants the JSON as a string instead of a dictionary object. DT seems to be able to handle the JSON object without using stringify though.

  • 1 accepted solution
  • 2054 Views
  • 5 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!