Fixed json encoding bug in thread