Fix JSON reader / writer examples
MODIFY
fastavro/json_read.py
fastavro/json_read.py
@@ -16,8 +16,21 @@ def json_reader(fo, schema):
Example::
from fastavro import json_reader
+
+ schema = {
+ 'doc': 'A weather reading.',
+ 'name': 'Weather',
+ 'namespace': 'test',
+ 'type': 'record',
+ 'fields': [
+ {'name': 'station', 'type': 'string'},
+ {'name': 'time', 'type': 'long'},
+ {'name': 'temp', 'type': 'int'},
+ ]
+ }
+
with open('some-file', 'r') as fo:
- avro_reader = json_reader(fo)
+ avro_reader = json_reader(fo, schema)
for record in avro_reader:
print(record)
"""

MODIFY
fastavro/json_write.py
fastavro/json_write.py
@@ -41,6 +41,6 @@ def json_writer(fo, schema, records):
]
with open('some-file', 'w') as out:
- writer(out, parsed_schema, records)
+ json_writer(out, parsed_schema, records)
"""
return writer(AvroJSONEncoder(fo), schema, records)

Fix JSON reader / writer examples