Skip to content

In the case of negative double value, it is formatted without including ".0" #486

@Akifumi-Yanai

Description

@Akifumi-Yanai

I am sorry that my English is so bad.

I'm using json-c 0.13.1.

If set negative double value, it will be formatted without including ".0".
Is this correct?

* PR#394: fix handling of custom double formats that include a ".0"

code:

struct json_object* json_obj = json_object_new_object();
struct json_object* positive_double_json_obj = json_object_new_double(12e+4);
struct json_object* negative_double_json_obj = json_object_new_double(-12e+4);
json_object_object_add(json_obj, "positive", positive_double_json_obj);
json_object_object_add(json_obj, "negative", negative_double_json_obj);

std::cout << "--- convert to string ---" << std::endl;
std::cout << json_object_to_json_string(json_obj) << std::endl;
std::cout << "-------------------------" << std::endl;

result:

--- convert to string ---
{ "positive": 120000.0, "negative": -120000 }
-------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions