how to get boost json to use the correct data types

前端 未结 1 1869
我在风中等你
我在风中等你 2021-01-20 13:36

When I put_value using an int, it gets written as a string. Does anyone know how to get it to print as an int?

#include 
#includ         


        
1条回答
  •  一整个雨季
    2021-01-20 14:37

    The library expressly doesn't support it.

    Boost Property Library has not been named "Boost Json Library" because it's not a JSON library. Instead, it's a Property Tree library (that happens to use JSON subsets for its purposes).

    From the documentation:

    The property tree dataset is not typed, and does not support arrays as such. Thus, the following JSON / property tree mapping is used:

    • JSON objects are mapped to nodes. Each property is a child node.
    • JSON arrays are mapped to nodes. Each element is a child node with an empty name. If a node has both named and unnamed child nodes, it cannot be mapped to a JSON representation.
    • JSON values are mapped to nodes containing the value. However, all type information is lost; numbers, as well as the literals "null", "true" and "false" are simply mapped to their string form.
    • Property tree nodes containing both child nodes and data cannot be mapped.

    And

    JSON round-trips, except for the type information loss.

    0 讨论(0)
提交回复
热议问题