I have a string which I'd like to parse into something meaningful i.e keys & values
The structure of it is a little weird in that it has a couple of lines as the header for each section, which seem to be a repeat of the info in that section. In the sample below, there are 2 sections, beginning with the lines:
Predicted class name: truck
Predicted class name: excavator
I really just need the 'display_name' and 'score' fields
There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.
Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.
can you copy the value (using the copy value button that appears under your mouse when you hover the debug value) & paste it as code (use the forums </> code button)
TBH, it looks like wherever that data is coming from (I'm guessing a python program) should really be modified to send clean/proper JSON.
Do you have access to the source program - a far better fix is to produce good JSON instead of parsing this tangle of strings. I'm not saying it isn't possible (you could very will split by line, remove brackets [ { } ], split by :, trim each value, parse the data type to a number, string or object & loop through it all) - just not ideal!
I think this is what I did in my first post- but I've done it again to be sure
NR seems to display the line break symbols in the debug window & when you click the output, or copy/paste, it is displayed with the lines
Could you share a minimal flow that results in this data?
E.g. no dashboard or custom nodes other than the node that you use to communicate your input to GC - use inject or change nodes to prepare the call to GC etc.