Skip to content

converts Structure or Union in ctypes to JSON.

License

Notifications You must be signed in to change notification settings

teilginn/ctypes_json

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ctypes_json.py

ctypes_json.py converts Structure or Union in ctypes to JSON.

Requirements

No dependencies.

Usage

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)

License

license

Copyright (c) 2017 Kenichiro IDA

About

converts Structure or Union in ctypes to JSON.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%