1
0
mirror of https://github.com/ultrajson/ultrajson.git synced 2024-11-24 05:12:02 +01:00
ultrajson/python/ujson.c
Kieran O'Mahony 79e980641d fix compiler warnings
& remove redundant enum
2012-06-12 12:04:59 +01:00

42 lines
1.6 KiB
C

#include <Python.h>
#include "version.h"
/* objToJSON */
PyObject* objToJSON(PyObject* self, PyObject *args, PyObject *kwargs);
void initObjToJSON(void);
/* JSONToObj */
PyObject* JSONToObj(PyObject* self, PyObject *arg);
/* objToJSONFile */
PyObject* objToJSONFile(PyObject* self, PyObject *args, PyObject *kwargs);
/* JSONFileToObj */
PyObject* JSONFileToObj(PyObject* self, PyObject *file);
static PyMethodDef ujsonMethods[] = {
{"encode", (PyCFunction) objToJSON, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursivly into JSON. Use ensure_ascii=false to output UTF-8. Pass in double_precision to alter the maximum digit precision with doubles"},
{"decode", (PyCFunction) JSONToObj, METH_O, "Converts JSON as string to dict object structure"},
{"dumps", (PyCFunction) objToJSON, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursivly into JSON. Use ensure_ascii=false to output UTF-8"},
{"loads", (PyCFunction) JSONToObj, METH_O, "Converts JSON as string to dict object structure"},
{"dump", (PyCFunction) objToJSONFile, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursively into JSON file. Use ensure_ascii=false to output UTF-8"},
{"load", (PyCFunction) JSONFileToObj, METH_O, "Converts JSON as file to dict object structure"},
{NULL, NULL, 0, NULL} /* Sentinel */
};
PyMODINIT_FUNC
initujson(void)
{
PyObject *module;
PyObject *version_string;
initObjToJSON();
module = Py_InitModule("ujson", ujsonMethods);
version_string = PyString_FromString (UJSON_VERSION);
PyModule_AddObject (module, "__version__", version_string);
}