Skip to content
Browse files

Add license and unicode strings

  • Loading branch information...
1 parent 268a54f commit 7301860eff619c7e392ac5b6cc4408a8f6e22c00 @matpow2 matpow2 committed Feb 13, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 bindings/python/wrap_json.c
View
9 bindings/python/wrap_json.c
@@ -42,10 +42,11 @@ PyObject * convert_value(json_value * data)
case json_object:
value = PyDict_New();
for (int i = 0; i < data->u.object.length; i++) {
- char * name = data->u.object.values[i].name;
+ PyObject * name = PyUnicode_FromString(
+ data->u.object.values[i].name);
PyObject * object_value = convert_value(
data->u.object.values[i].value);
- PyDict_SetItemString(value, name, object_value);
+ PyDict_SetItem(value, name, object_value);
}
break;
case json_array:
@@ -63,7 +64,7 @@ PyObject * convert_value(json_value * data)
value = PyFloat_FromDouble(data->u.dbl);
break;
case json_string:
- value = PyString_FromStringAndSize(data->u.string.ptr,
+ value = PyUnicode_FromStringAndSize(data->u.string.ptr,
data->u.string.length);
break;
case json_boolean:
@@ -82,7 +83,7 @@ PyObject * decode_json(char * data)
{
json_settings settings;
memset(&settings, 0, sizeof (json_settings));
- char error [256];
+ char error[256];
json_value * value = json_parse_ex(&settings, data, error);
if (value == 0) {
return PyErr_Format(json_exception, error);

0 comments on commit 7301860

Please sign in to comment.
Something went wrong with that request. Please try again.