1
0
mirror of https://github.com/ultrajson/ultrajson.git synced 2024-11-24 05:12:02 +01:00

- Fixed X.0 values to be encoded as "X.0" instead of "X"

This commit is contained in:
Jonas Trnstrm 2011-04-26 21:00:59 +02:00
parent 9468a8720e
commit bd283e7020
5 changed files with 15 additions and 18 deletions

@ -18,6 +18,7 @@ extern "C"
//char indata[] = "R├ñksm├Ârg├Ñs ϺÏ│Ϻ┘àÏ® Ï¿┘å ┘àÏ¡┘àÏ» Ï¿┘å Ï╣┘êÏ Ͽ┘å ┘äϺϻ┘å";
//char indata[] = "\"اسامة بن محمد بن عوض بن لادن,\"";
char indata[] = "\"\xe6\x97\xa5\xd1\x88\"";
//char indata[] =
//char indata[] = "\x19";
/*
\xe6\x97\xa5\xd1\x88\xf0\x9d\x84\x9e*/
@ -571,25 +572,11 @@ int main (int argc, char **argv)
decoder.realloc = realloc;
decoder.releaseObject = Object_releaseObject;
obj = new DoubleObject(1.0);
char buffer[65536];
#define N 10000
JSON_EncodeObject(obj, &encoder, buffer, sizeof(buffer));
char *input = (char *) malloc((2 * 1024 * 1024 * 10) + 3);
input[0] = '"';
for (int index = 1; index < (1024 * 1024 * 10) - 1; index += 2)
{
input[index + 0] = '\xc3';
input[index + 1] = '\xa5';
}
input[(1024 * 1024 * 10)] = '"';
input[(1024 * 1024 * 10)+ 1] = '\0';
BaseObject *obj2 = (BaseObject *) JSON_DecodeObject(&decoder, input, strlen(input));
/*

@ -1,5 +1,5 @@
#include <Python.h>
#include "../ultrajson.h"
#include <ultrajson.h>

Binary file not shown.

@ -16,6 +16,11 @@ class UltraJSONTests(TestCase):
self.assertEquals(round(input, 5), round(json.loads(output), 5))
self.assertEquals(round(input, 5), round(ujson.decode(output), 5))
pass
def test_encodeWithDecimal(self):
input = 1.0
output = ujson.encode(input)
self.assertEquals(output, "1.0")
def test_encodeDoubleNegConversion(self):
input = -math.pi

@ -476,6 +476,11 @@ int Buffer_AppendDoubleUnchecked(JSOBJ obj, JSONObjectEncoder *enc, double value
// add decimal
*wstr++ = '.';
}
else
{
*wstr++ = '0';
*wstr++ = '.';
}
// do whole part
// Take care of sign