def test_json_choice():
  class Foo(Struct):
    a = String
    b = Integer
  class Yuck(Struct):
    one = Choice([Foo, Integer])
    two = String

  z = Yuck(one=Foo(a="1", b=2), two="hello")
  assert z.check().ok()

  d = json.loads(z.json_dumps())
  assert d == {"two": "hello", "one": {"a": "1", "b": 2}}
Make sure that serializing to JSON works for structs with choices.
dataset/ETHPy150Open wickman/pystachio/tests/test_choice.py/test_json_choice