I stored a field of records as JSON "[1,2,3,14,4]"
In MySQL 5.7, I used JSON_LENGTH to count it.
But How can I count in MySQL 5.5.
This is my example query in MySQL 5.7.
SELECT JSON_LENGTH(view_cnt) AS view_cnt FROM `tbl` WHERE `published`=1
Since mysql v5.5 does not have any json support, you need to get creative using string functions.
If your json is simple and does not have values that themselves contain comma, then just count then number of commas within your string and add 1 to it:
select char_length(json_field)-char_length(replace(json_field,',',''))+1 from table
If your json values contain commas, then you would have to write a json parser in mysql to get the length.