make json bidirectional (based on #572)