json encoding of structure