Fix exception in Value::ToJson().

Refs #5049