Skip to content
Snippets Groups Projects
Commit d65cfbf7 authored by jay's avatar jay
Browse files

Adds the np encoder for JSON arrays

parent 71909a32
No related branches found
No related tags found
No related merge requests found
import json import json
import numpy as np
class NumpyEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, np.ndarray):
return obj.tolist()
elif isinstance(obj, datetime.date):
return obj.isoformat()
return json.JSONEncoder.default(self, obj)
def read_json(inputfile): def read_json(inputfile):
""" """
Read the input json file into a python dictionary. Read the input json file into a python dictionary.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment