Encodes a value to a json string.
This is a typed wrapper around the toValue method.
String toJson<T>(T object);