I have a string with concatenated values done on MySQL as below:
CONCAT("[\"",GROUP_CONCAT(DISTINCT(concat_ws("=>",val_1, val_2,val_3)) ORDER BY val_4 DESC SEPARATOR "\",\""),"\"]")
I have noticed that the output of each row seems incomplete, from a var_dump
it seems like that:
"["CONFECTIONERY=>BISCUITS=>CRACKERS",
"CONFECTIONERY=>BISCUITS=>COOKIES",
"ORIENTAL GROCERY=>KOREAN GROCERY=>KOREAN FOOD (DRY, PACKET)",
"BEVERAGE=>COFFEE=>PREMIX COFFEE POWDER",
"CLEANING AGENT & PEST CONTROL=>LAUNDRY=>LAUNDRY LIQUID",
"CLEANING AGENT & PEST CONTROL=>LAUNDRY=>LAUNDRY POWDER",
"BEVERAGE=>TEA=>WESTERN TEA",
"CEREAL & SPREADS=>CEREAL=>"
It is missing the ending square bracket and also the third element after the => character. And also the other lines are interrupted at the same position.
If I try to json_decode
in PHP this output I get NULL probably because is not well encoded, since the longest lines (more than 345 characters) are cutted.
Or maybe is a problem related to the length of the string? Cause I have noticed that are very long and they interrupt at the same position as characters. See the screenshot below of the output on mysqlworkbench:
I have also counted and exactly each row has 345 characters and it breaks at the same point. It doesn't seems a coincidence:
From what I can see I should have escaped correctly the characters. Any suggestions?