免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4639 | 回复: 19
打印 上一主题 下一主题

[C++] jsoncpp如何获取大数(1亿亿) [复制链接]

论坛徽章:
5
戌狗
日期:2014-06-09 10:29:10酉鸡
日期:2014-12-01 16:05:27处女座
日期:2015-01-07 18:35:262015亚冠之水原三星
日期:2015-06-03 09:26:222015亚冠之布里斯班狮吼
日期:2015-06-15 10:53:54
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-11-10 20:56 |只看该作者 |倒序浏览
之前用jsoncpp解释json串,主要用asInt(),asString()两个函数来获取数据,可是今天遇到一个1亿亿的数,无法获取,请问如何处理?
报错:Real out of unsigned integer range

难道改用其他库?

论坛徽章:
36
子鼠
日期:2013-08-28 22:23:29黄金圣斗士
日期:2015-12-01 11:37:51程序设计版块每日发帖之星
日期:2015-12-14 06:20:00CU十四周年纪念徽章
日期:2015-12-22 16:50:40IT运维版块每日发帖之星
日期:2016-01-25 06:20:0015-16赛季CBA联赛之深圳
日期:2016-01-27 10:31:172016猴年福章徽章
日期:2016-02-18 15:30:3415-16赛季CBA联赛之福建
日期:2016-04-07 11:25:2215-16赛季CBA联赛之青岛
日期:2016-04-29 18:02:5915-16赛季CBA联赛之北控
日期:2016-06-20 17:38:50技术图书徽章
日期:2016-07-19 13:54:03程序设计版块每日发帖之星
日期:2016-08-21 06:20:00
2 [报告]
发表于 2015-11-10 21:05 |只看该作者
数据来源方写成字符串,得到字符串,用大数库

论坛徽章:
89
水瓶座
日期:2014-04-01 08:53:31天蝎座
日期:2014-04-01 08:53:53天秤座
日期:2014-04-01 08:54:02射手座
日期:2014-04-01 08:54:15子鼠
日期:2014-04-01 08:55:35辰龙
日期:2014-04-01 08:56:36未羊
日期:2014-04-01 08:56:27戌狗
日期:2014-04-01 08:56:13亥猪
日期:2014-04-01 08:56:02亥猪
日期:2014-04-08 08:38:58程序设计版块每日发帖之星
日期:2016-01-05 06:20:00程序设计版块每日发帖之星
日期:2016-01-07 06:20:00
3 [报告]
发表于 2015-11-11 08:49 |只看该作者
这就算大了,不会吧。

论坛徽章:
5
戌狗
日期:2014-06-09 10:29:10酉鸡
日期:2014-12-01 16:05:27处女座
日期:2015-01-07 18:35:262015亚冠之水原三星
日期:2015-06-03 09:26:222015亚冠之布里斯班狮吼
日期:2015-06-15 10:53:54
4 [报告]
发表于 2015-11-11 09:38 |只看该作者
回复 2# cokeboL


    不是一个部门,这个有点难度。。。

论坛徽章:
5
戌狗
日期:2014-06-09 10:29:10酉鸡
日期:2014-12-01 16:05:27处女座
日期:2015-01-07 18:35:262015亚冠之水原三星
日期:2015-06-03 09:26:222015亚冠之布里斯班狮吼
日期:2015-06-15 10:53:54
5 [报告]
发表于 2015-11-11 09:39 |只看该作者
fender0107401 发表于 2015-11-11 08:49
这就算大了,不会吧。


。。。。请问用jsoncpp怎么处理?

论坛徽章:
324
射手座
日期:2013-08-23 12:04:38射手座
日期:2013-08-23 16:18:12未羊
日期:2013-08-30 14:33:15水瓶座
日期:2013-09-02 16:44:31摩羯座
日期:2013-09-25 09:33:52双子座
日期:2013-09-26 12:21:10金牛座
日期:2013-10-14 09:08:49申猴
日期:2013-10-16 13:09:43子鼠
日期:2013-10-17 23:23:19射手座
日期:2013-10-18 13:00:27金牛座
日期:2013-10-18 15:47:57午马
日期:2013-10-18 21:43:38
6 [报告]
发表于 2015-11-11 09:48 |只看该作者
  Int asInt() const;
  UInt asUInt() const;
#if defined(JSON_HAS_INT64)
  Int64 asInt64() const;
  UInt64 asUInt64() const;
#endif // if defined(JSON_HAS_INT64)
  LargestInt asLargestInt() const;
  LargestUInt asLargestUInt() const;

论坛徽章:
36
子鼠
日期:2013-08-28 22:23:29黄金圣斗士
日期:2015-12-01 11:37:51程序设计版块每日发帖之星
日期:2015-12-14 06:20:00CU十四周年纪念徽章
日期:2015-12-22 16:50:40IT运维版块每日发帖之星
日期:2016-01-25 06:20:0015-16赛季CBA联赛之深圳
日期:2016-01-27 10:31:172016猴年福章徽章
日期:2016-02-18 15:30:3415-16赛季CBA联赛之福建
日期:2016-04-07 11:25:2215-16赛季CBA联赛之青岛
日期:2016-04-29 18:02:5915-16赛季CBA联赛之北控
日期:2016-06-20 17:38:50技术图书徽章
日期:2016-07-19 13:54:03程序设计版块每日发帖之星
日期:2016-08-21 06:20:00
7 [报告]
发表于 2015-11-11 10:04 |只看该作者
本帖最后由 cokeboL 于 2015-11-11 10:05 编辑

     

论坛徽章:
5
戌狗
日期:2014-06-09 10:29:10酉鸡
日期:2014-12-01 16:05:27处女座
日期:2015-01-07 18:35:262015亚冠之水原三星
日期:2015-06-03 09:26:222015亚冠之布里斯班狮吼
日期:2015-06-15 10:53:54
8 [报告]
发表于 2015-11-11 13:19 |只看该作者
hellioncu 发表于 2015-11-11 09:48
Int asInt() const;
  UInt asUInt() const;
#if defined(JSON_HAS_INT64)


。。。你用的是哪个版本??
我的是jsoncpp-src-0.5.0,value.h文件中只有
      int compare( const Value &other );

      const char *asCString() const;
      std::string asString() const;
# ifdef JSON_USE_CPPTL
      CppTL::ConstString asConstString() const;
# endif
      Int asInt() const;
      UInt asUInt() const;
      double asDouble() const;
      bool asBool() const;

论坛徽章:
324
射手座
日期:2013-08-23 12:04:38射手座
日期:2013-08-23 16:18:12未羊
日期:2013-08-30 14:33:15水瓶座
日期:2013-09-02 16:44:31摩羯座
日期:2013-09-25 09:33:52双子座
日期:2013-09-26 12:21:10金牛座
日期:2013-10-14 09:08:49申猴
日期:2013-10-16 13:09:43子鼠
日期:2013-10-17 23:23:19射手座
日期:2013-10-18 13:00:27金牛座
日期:2013-10-18 15:47:57午马
日期:2013-10-18 21:43:38
9 [报告]
发表于 2015-11-11 13:22 |只看该作者
kaede_1 发表于 2015-11-11 13:19
。。。你用的是哪个版本??
我的是jsoncpp-src-0.5.0,value.h文件中只有
      int compare( const ...


刚下的,看样子是新增加的特性

  New in JsonCpp 0.6.0:
  ---------------------

* Compilation

  - LD_LIBRARY_PATH and LIBRARY_PATH environment variables are now
    propagated to the build environment as this is required for some
    compiler installation.

  - Added support for Microsoft Visual Studio 2008 (bug #2930462):
    The platform "msvc90" has been added.

    Notes: you need to setup the environment by running vcvars32.bat
    (e.g. MSVC 2008 command prompt in start menu) before running scons.
   
  - Added support for amalgamated source and header generation (a la sqlite).
    Refer to README.md section "Generating amalgamated source and header"
    for detail.
   
* Value

  - Removed experimental ValueAllocator, it caused static
    initialization/destruction order issues (bug #2934500).
    The DefaultValueAllocator has been inlined in code.
   
  - Added support for 64 bits integer:
  
    Types Json::Int64 and Json::UInt64 have been added. They are aliased
        to 64 bits integers on system that support them (based on __int64 on
        Microsoft Visual Studio platform, and long long on other platforms).
       
        Types Json::LargestInt and Json::LargestUInt have been added. They are
        aliased to the largest integer type supported:
        either Json::Int/Json::UInt or Json::Int64/Json::UInt64 respectively.
       
        Json::Value::asInt() and Json::Value::asUInt() still returns plain
        "int" based types, but asserts if an attempt is made to retrieve
        a 64 bits value that can not represented as the return type.
       
        Json::Value::asInt64() and Json::Value::asUInt64() have been added
        to obtain the 64 bits integer value.
       
        Json::Value::asLargestInt() and Json::Value::asLargestUInt() returns
        the integer as a LargestInt/LargestUInt respectively. Those functions
        functions are typically used when implementing writer.
       
        The reader attempts to read number as 64 bits integer, and fall back
        to reading a double if the number is not in the range of 64 bits
        integer.
   
    Warning: Json::Value::asInt() and Json::Value::asUInt() now returns
    long long. This changes break code that was passing the return value
    to *printf() function.
  
    Support for 64 bits integer can be disabled by defining the macro
        JSON_NO_INT64 (uncomment it in json/config.h for example), though
        it should have no impact on existing usage.
   

论坛徽章:
5
戌狗
日期:2014-06-09 10:29:10酉鸡
日期:2014-12-01 16:05:27处女座
日期:2015-01-07 18:35:262015亚冠之水原三星
日期:2015-06-03 09:26:222015亚冠之布里斯班狮吼
日期:2015-06-15 10:53:54
10 [报告]
发表于 2015-11-11 14:14 |只看该作者
果然,多谢

之前一时没有方法,直接字符串匹配了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP