79374724

Date: 2025-01-21 14:12:34
Score: 0.5
Natty:
Report link

Using fastavro in 2025 (https://fastavro.readthedocs.io/en/latest/writer.html)

        schema_json = {
                "type": "record",
                "name": "User",
                "namespace": "com.test",
                "fields": [
                    {"name": "person_name", "type": "string"},
                    {"name": "age", "type": "int"},
                    {"name": "email", "type": "string"}
                ]
            }
        

        data_user_1 = {"person_name": "John Doe", "email": "[email protected]", "age": 30}
        data_user_2 = {"person_name": "Jane Doe",  "email": "[email protected]", "age": 25}

        parsed_schema = parse_schema(schema_json)

        bytes_io = BytesIO()
        writer(bytes_io, parsed_schema, [data_user_1, data_user_2])
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: frankmurphy