0

We have a correct and clean json string in a text column in Postgres, this string is a sort of configuration data rarely changed.

The json string is fetched from java code running in a web application on wildfly via jdbi query.

Only on linux systems we experience the presence of control characters (?) when reading the string from resultSet (with a getString("param_value")). Here the json text saved after the read from resultSet.

Any suggestion?

angcap
  • 149
  • 2
  • 9
  • How have you verified that it is "correct and clean"? Also, show the source you use to save the json text that gives that result. – RealSkeptic Feb 06 '17 at 16:20

1 Answers1

0

I don't know WHY this happen, but i've tested the code in unit test with the same results obtained in application server environment (windows ok, linux ko). Furthermore, nothing changes after both postgres jdbc driver and jdbi driver upgrade.

As WORKAROUND to avoid problems when parsing json, a string replace of control character is performed:

String jsonString = resultSet.getString("param_value")
                      .replaceAll("[\\x00-\\x1F\‌​\x7F\\x0A\\xfffd\\x2‌​0a]","");

The sequence of control character was initially taken from this post, then extended based on json parsing exception messages.

Community
  • 1
  • 1
angcap
  • 149
  • 2
  • 9