improved JSON message detection