Translate filter errors on 's values

I've got an id that I want to translate to 4 other variables so having read over the forum I found a suggestion to use JSON to make life easier on myself but some records are giving me issues

'1148' : '{"description": "Fred's ball","colour":"blue", "shape":"Round", "Reference":"USUFK93"}'

when it hit's thie part of the dictionary I get
[2019-02-15T16:50:30,680][ERROR][logstash.pipeline ] Error registering plugin {:pipeline_id=>"example", :plugin=>"#<LogStash::FilterDelegator:0x7b604cf6>", : error=>"Translate: (<unknown>): expected <block end>, but found Scalar while parsing a block mapping at line 83 column 33 when loading dictionary file at /dictionarys/translate.yml, :thread=>"#<Thread:0x1fc0bacf run>"}

as it sees the single quote in Fred's ball and sees it as the end of the value missing the rest of the JSON and throwing the error.

has anyone got any ideas on how I might work around this?

If you are OK with having the JSON parsed automatically then use

'1148' : {"description": "Fred's ball","colour":"blue", "shape":"Round", "Reference":"USUFK93"}

then your translation target will be an object containing those 4 fields. If you do not want it parsed then use a second single quote to escape the first

'1148' : '{"description": "Fred''s ball","colour":"blue", "shape":"Round", "Reference":"USUFK93"}'

sorry for the late reply, been under the weather so took a while to circle back, but that worked a treat thanks @Badger

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.