|
1 |
| -#include <Python.h> |
2 |
| -#include "version.h" |
3 |
| - |
4 |
| -/* objToJSON */ |
5 |
| -PyObject* objToJSON(PyObject* self, PyObject *args, PyObject *kwargs); |
6 |
| -void initObjToJSON(void); |
7 |
| - |
8 |
| -/* JSONToObj */ |
9 |
| -PyObject* JSONToObj(PyObject* self, PyObject *args, PyObject *kwargs); |
10 |
| - |
11 |
| -/* objToJSONFile */ |
12 |
| -PyObject* objToJSONFile(PyObject* self, PyObject *args, PyObject *kwargs); |
13 |
| - |
14 |
| -/* JSONFileToObj */ |
15 |
| -PyObject* JSONFileToObj(PyObject* self, PyObject *args, PyObject *kwargs); |
16 |
| - |
17 |
| - |
18 |
| -static PyMethodDef ujsonMethods[] = { |
19 |
| - {"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"}, |
20 |
| - {"decode", (PyCFunction) JSONToObj, METH_VARARGS | METH_KEYWORDS, "Converts JSON as string to dict object structure"}, |
21 |
| - {"dumps", (PyCFunction) objToJSON, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursivly into JSON. Use ensure_ascii=false to output UTF-8"}, |
22 |
| - {"loads", (PyCFunction) JSONToObj, METH_VARARGS | METH_KEYWORDS, "Converts JSON as string to dict object structure"}, |
23 |
| - {"dump", (PyCFunction) objToJSONFile, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursively into JSON file. Use ensure_ascii=false to output UTF-8"}, |
24 |
| - {"load", (PyCFunction) JSONFileToObj, METH_VARARGS | METH_KEYWORDS, "Converts JSON as file to dict object structure"}, |
25 |
| - {NULL, NULL, 0, NULL} /* Sentinel */ |
26 |
| -}; |
27 |
| - |
28 |
| - |
29 |
| - |
30 |
| -PyMODINIT_FUNC |
31 |
| -init_ujson(void) |
32 |
| -{ |
33 |
| - PyObject *module; |
34 |
| - PyObject *version_string; |
35 |
| - |
36 |
| - initObjToJSON(); |
37 |
| - module = Py_InitModule("_ujson", ujsonMethods); |
38 |
| - |
39 |
| - version_string = PyString_FromString (UJSON_VERSION); |
40 |
| - PyModule_AddObject (module, "__version__", version_string); |
41 |
| -} |
| 1 | +#include <Python.h> |
| 2 | +#include "version.h" |
| 3 | + |
| 4 | +/* objToJSON */ |
| 5 | +PyObject* objToJSON(PyObject* self, PyObject *args, PyObject *kwargs); |
| 6 | +void initObjToJSON(void); |
| 7 | + |
| 8 | +/* JSONToObj */ |
| 9 | +PyObject* JSONToObj(PyObject* self, PyObject *args, PyObject *kwargs); |
| 10 | + |
| 11 | +/* objToJSONFile */ |
| 12 | +PyObject* objToJSONFile(PyObject* self, PyObject *args, PyObject *kwargs); |
| 13 | + |
| 14 | +/* JSONFileToObj */ |
| 15 | +PyObject* JSONFileToObj(PyObject* self, PyObject *args, PyObject *kwargs); |
| 16 | + |
| 17 | + |
| 18 | +static PyMethodDef ujsonMethods[] = { |
| 19 | + {"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"}, |
| 20 | + {"decode", (PyCFunction) JSONToObj, METH_VARARGS | METH_KEYWORDS, "Converts JSON as string to dict object structure"}, |
| 21 | + {"dumps", (PyCFunction) objToJSON, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursivly into JSON. Use ensure_ascii=false to output UTF-8"}, |
| 22 | + {"loads", (PyCFunction) JSONToObj, METH_VARARGS | METH_KEYWORDS, "Converts JSON as string to dict object structure"}, |
| 23 | + {"dump", (PyCFunction) objToJSONFile, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursively into JSON file. Use ensure_ascii=false to output UTF-8"}, |
| 24 | + {"load", (PyCFunction) JSONFileToObj, METH_VARARGS | METH_KEYWORDS, "Converts JSON as file to dict object structure"}, |
| 25 | + {NULL, NULL, 0, NULL} /* Sentinel */ |
| 26 | +}; |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +PyMODINIT_FUNC |
| 31 | +init_ujson(void) |
| 32 | +{ |
| 33 | + PyObject *module; |
| 34 | + PyObject *version_string; |
| 35 | + |
| 36 | + initObjToJSON(); |
| 37 | + module = Py_InitModule("_ujson", ujsonMethods); |
| 38 | + |
| 39 | + version_string = PyString_FromString (UJSON_VERSION); |
| 40 | + PyModule_AddObject (module, "__version__", version_string); |
| 41 | +} |
0 commit comments