I have REST written in Java and the JSON response message is not valid.
I have messages defined in single file messages.properties. I expect that response should be something like that:
NOT_FOUND_PERSON = Person doesn't exist
However I got response with missing spelling:
['errorMsg': 'Person doesnt exist.']
Where is the problem? Cannot be due to wrong setup ResourceBundleMessageSource in config? I noticed there is missing UTF8 coding. Is there problem with some hide escape function or whatever?
I found the solution. The problem was with quotation mark in messages.properties. In default, spring uses message bundle to represent messages from properties file. Any occurences of quotation mark must be escaped by single quote otherwise it won't be displayed properly.
This
test.message2={0}'s message
must be replaced by this
test.message2={0}''s message
Resource: https://www.mscharhag.com/java/resource-bundle-single-quote-escaping