fixed DoubleToJSON() implementation, which was not thread-safe