ctypes_json.py
converts Structure or Union in ctypes to JSON.
No dependencies.
import json
from ctypes import Structure, c_int
from ctypes_json import CDataJSONEncoder
class Data(Structure):
_fields_ = [
('a', c_int),
('b', c_int),
('c', c_int),
]
data = Data()
data.a = 10
data.b = 20
data.c = 30
json.dumps(data, cls=CDataJSONEncoder)
Copyright (c) 2017 Kenichiro IDA