0

I have MySql query that will return as JSON_Array from MySql DB.

Query:-

SELECT id,
       JSON_ARRAY(GROUP_CONCAT(address))
FROM tb_address
GROUP BY id;

But I can't find proper variable type to receive that return value in Java. Someone can share the some code to handle the MySQL JSON_ARRAY.

NikuNj Rathod
  • 1,663
  • 1
  • 17
  • 26
JohnC
  • 209
  • 4
  • 16
  • would it not just be a String ? – Scary Wombat Dec 22 '17 at 02:37
  • Meaning need to parse to JSON format? (I'm quite new with MySQL JSON var) – JohnC Dec 22 '17 at 02:41
  • What have you tried? Show your work. I feel that if it works at all it may be a String and then you can maybe use Jackson or GSON to convert to JSON Obejcts – Scary Wombat Dec 22 '17 at 02:44
  • I haven't tried with String, Coz I thought it's rs.getArray("name") and received as Array or JSONArray. Will try receive as String and parse to JSON format. – JohnC Dec 22 '17 at 02:48
  • i think simply you can return the string & convert it in to a object or json Oject. Ex: JSONParser parser = new JSONParser(); JSONObject json = (JSONObject) parser.parse(stringToParse); – Chamara Maduranga Dec 22 '17 at 04:51

0 Answers0