JSON Newline Delimited question

OK so I am trying to do an event breaker to break some JSON data that comes in. Each event will start with

{
“data”: {
—JSON DATA HERE—
}
}

The problem is that the last 2 curly brackets have a line break as shown below

image

This breaks the JSON and makes the last curly bracket a separate event

Any help getting this to not break like that would be great.

What type of event breaker are you using? I’d recommend regex based and break on something like (?=\n\})\n

yeah that works but it does not take account that last } which is part of the complete JSON event

I would use something like this in the Event Breaker Regex: (?<=}$).(?=^{)

Screen Shot 2022-05-25 at 7.34.11 AM

1 UpGoat

For the most part, this works, but somehow when using this breaker, it is adding [object Object] into the data. I dont know why or how but it does. I thought this was only in one line so I am dropping it, but apparently it is not so I am actually throwing away valid data. Is there any other way to break these events up? JSON New Line almost gets it but i am in the same boat as it takes the last } of the first JSON event and adds it to the next event. Essentially I get }{ in the next event, where the } needs to stay in the event above it and the { remains in the next event.

can you DM me a cleansed sample dataset? I’ll experiment :slight_smile:

Actually I fixed this by piping my script output to jq to make it come in as an array, which is much easier to use with an event breaker. My issues is resolved.

1 UpGoat