Safe, cross-language JSON encoding/decoding of structures containing circular references