HDF5 To JSON Conversion Error


#1

Hi,

I am currently trying to convert an HDF5 file to JSON using this library here : https://github.com/HDFGroup/hdf5-json

but running into an issue with types as below:

File “/home/hdfs/envs/parser_env/lib/python3.8/site-packages/h5json-1.1.3-py3.8.egg/h5json/h5tojson/h5tojson.py”, line 244, in main
dumper.dumpFile()
File “/home/hdfs/envs/parser_env/lib/python3.8/site-packages/h5json-1.1.3-py3.8.egg/h5json/h5tojson/h5tojson.py”, line 204, in dumpFile
print(json.dumps(self.json, sort_keys=True, indent=4))
File “/usr/local/lib/python3.8/json/init.py”, line 234, in dumps
return cls(
File “/usr/local/lib/python3.8/json/encoder.py”, line 201, in encode
chunks = list(chunks)
File “/usr/local/lib/python3.8/json/encoder.py”, line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File “/usr/local/lib/python3.8/json/encoder.py”, line 405, in _iterencode_dict
yield from chunks
File “/usr/local/lib/python3.8/json/encoder.py”, line 405, in _iterencode_dict
yield from chunks
File “/usr/local/lib/python3.8/json/encoder.py”, line 405, in _iterencode_dict
yield from chunks
File “/usr/local/lib/python3.8/json/encoder.py”, line 325, in _iterencode_list
yield from chunks
File “/usr/local/lib/python3.8/json/encoder.py”, line 438, in _iterencode
o = _default(o)
File “/usr/local/lib/python3.8/json/encoder.py”, line 179, in default
raise TypeError(f’Object of type {o.class.name} ’
TypeError: Object of type bytes is not JSON serializable

I understand that this is because JSON expect strings and not bytes but I am not sure what is causing this error in the HDF5 file to see if I can convert it into string before the JSON conversion. Do you know any workarounds for this?


#2

This issue is being discussed at the h5json package GitHub repository.

Aleksandar