Closed kematy closed 5 years ago
This is not the case with integers.
In my operating system (win10), when I execute the EXE I generate, as long as the integer is incremented by a small enough number, it can be parsed by cjson。
I suspect this is a matter of the compiler handling floating-point precision
The compiler I use is mingw32 7.4.0。
on trip, I will reply this weekend.
---Original--- From: "kematy"notifications@github.com Date: Tue, Jul 16, 2019 20:25 PM To: "Bwar/CJsonObject"CJsonObject@noreply.github.com; Cc: "Subscribed"subscribed@noreply.github.com; Subject: Re: [Bwar/CJsonObject] even if you give an initial value to a float variable, json parsing gives you an initial value. Without the initial value, the result is a little bit like 4.6085e+33. (#1)
The compiler I use is mingw32 7.4.0。
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Waiting for your good news。祝你旅途愉快!
另外,这个cjsonobject 怎么识别null和true、false,这也是经常要用到的。好像没有这样的实例函数,只有一个IsEmpty()?
问题不在.Get(0,fvalue),在cJSON.c里的print_double(),在你的例子中做了json赋值,赋值时ToString()方法会调用print_double(),而print_double()将.0截掉了,值变成了整数。 另外,你提到的null,我也加入了对null的支持,不过建议能不用null就尽量别用null,null虽然是json属于json标准,但用在C++这种强类型语言里不是太合适,明确一个json value是string、int、float或{}又或[]会更好。
非常感谢,试过了,已经比较完善了,感谢你的辛劳和付出。
In my case, even if you give an initial value to a float variable, json parsing gives you an initial value. Without the initial value, the result is a little bit like 4.6085e+33. jsontest.zip