Json array - target a specific text in value

Hello n8n community,

As a result of reading a PDF the JSON output looks like this :

I need some help on how to target a specific text in value "Bill of Landing Number:"using the function node.

Thank you in advance.

I believe the way to do this is with a Set Node, you can call the JSON element ‘text’ just with {{$node[“Name of the node generating the JSON output”].json[“text”]}}. The use a RegEx to find the value that follows “Bill of Lading Number:”.

This would assume that the structure of your BOL is the same for each conversion , you might run into some problems if you are using BOL’s from different Carriers, for instance.

Refer to https://regex101.com/ to work out what your expression needs to look like, and there are a few useful beginner guides (Learn Regex: A Beginner's Guide - SitePoint) that have helped me build expressions with no prior knowledge.

You can then use the RegEx within your JSON expression with .match(), so it would look something like: {{$node[“Name of the node generating the JSON output”].json[“text”].match(/Your RegEx/)}}

Somebody else here might be able to steer you in another direction, but this is how I would tackle the problem!

4 Likes

Thank you for your replay @Felix_is_stuck

Yes the file is gonna have the same structure.
But the solution did not work for me.

I believe the way to do this is with a Set Node, you can call the JSON element ‘text’ just with {{$node[“Name of the node generating the JSON output”].json[“text”]}}. The use a RegEx to find the value that follows “Bill of Lading Number:”.

This gave me the whole content of “text”. While as you can see in the screenshot i need to get a specific value it.

That’s correct, {{$node[“Name of the node generating the JSON output”].json[“text”]}} will give you the complete value. You need to add a RegEx formula to extract only the data that you want and add that formula by appending .match(formula) to your expression.

I suggest you start by reading the guide I posted above, it will help you to understand RegEx formulas.

1 Like

@Felix_is_stuck
You are right, i got the output i was expecting.

image

Thank you so much

1 Like