Skip to content

Commit

Permalink
only strip label quotes if they exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Komnomnomnom committed May 3, 2012
1 parent 835789f commit 5d17dbb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/objToJSON.c
Expand Up @@ -330,9 +330,13 @@ void NpyIter_encodeLabel(JSONTypeContext* tc, NpyIterContext* npyiter, PyObject*
PyObject* labelObj = PyArray_GETITEM(labels, labelItem);
JSONObjectEncoder* labelEncoder = ((PyObjectEncoder*)tc->encoder)->labelEncoder;

// encode the label, ensuring that we trim off the quotes surrounding the result
GET_TC(tc)->citemName = JSON_EncodeObject(labelObj, labelEncoder, labelEncoder->start, labelEncoder->end - labelEncoder->start) + 1;
*(labelEncoder->offset-2) = '\0';
GET_TC(tc)->citemName = JSON_EncodeObject(labelObj, labelEncoder, labelEncoder->start, labelEncoder->end - labelEncoder->start);
// trim off any quotes surrounding the result
if (GET_TC(tc)->citemName[0] == '\"')
{
GET_TC(tc)->citemName++;
*(labelEncoder->offset-2) = '\0';
}
}

int NpyIter_iterNext(JSOBJ _obj, JSONTypeContext *tc)
Expand Down

0 comments on commit 5d17dbb

Please sign in to comment.