Comments (11)
也许你需要的是显示数字的 int8_t这种类型?但是似乎目前还没有支持,因为担心其与char的兼容性。
是的 我实际需要的是 uint8_t这种类型。 这种类型在和嵌入式设备通信中经常用到。希望能够支持上。
from iguana.
其中char是 0xa1, ascii码数字为161,并不是有效的ASCII码数字。然后 0x11,是17,是控制字符,这些字符不能正常显示也是合理的吧
from iguana.
也许你需要的是显示数字的 int8_t这种类型?但是似乎目前还没有支持,因为担心其与char的兼容性。
from iguana.
也许你需要的是显示数字的 int8_t这种类型?但是似乎目前还没有支持,因为担心其与char的兼容性。
是的 我实际需要的是 uint8_t这种类型。 这种类型在和嵌入式设备通信中经常用到。希望能够支持上。
关于char 这种数据结构,可以考虑用 类似 hex字符串的形式 。
from iguana.
其中char是 0xa1, ascii码数字为161,并不是有效的ASCII码数字。然后 0x11,是17,是控制字符,这些字符不能正常显示也是合理的吧
这里应该不只是不能显示。还会导致 输出的字符串不满足json 的规则。无法解析。 或者不支持的情况下,直接跳过或者空。
from iguana.
@RichardsATcn 有其它什么json 库支持这种输出吗?
from iguana.
@RichardsATcn 有其它什么json 库支持这种输出吗?
目前我也没有找到其他c++的json库支持这种输出。c++的反射获取成本实在太高了。
由于 uint8_t 刚好是8位处理器的一个寄存器长度。 uint8_t这种类型,不仅仅会单个出现,还有会用到 uint8_t data[10]。因为处理器资源的情况。很少使用类似 array动态数组。这种定长的结构体可以直接 通过1字节对齐的方式,直接拷贝内存块获得字节序列,用于传输。
我下面这几种种输出方式都是自己在项目中使用Qt QGadget的反射 配合人工编码获得的。 之所以除了base64 的方式 还用hex的方式,因为嵌入式工程师调试协议时候对 hex会比base64敏感的多。
uint8_t u8 = 0x22; // => { "U8": "0x22"}
uint8_t u8Buf[10] ;// => { "U8BUF": "064|base64 str"}
uint8_t u8Buf[10] ; // => { "U8BUF": "016|AABBCC"}
from iguana.
我尝试支持一下uint8吧那,如果支持了uint8你的问题可以得到解决了吗?
from iguana.
我刚刚测试了一下,gcc和clang可以区分开int8_t 、uint8_t与char的,windows应该也可以!但是我不知道您的编译器是否可以,
from iguana.
支持了uint8和int8,可以拉取最新的代码试试看
from iguana.
我刚刚测试了一下,gcc和clang可以区分开int8_t 、uint8_t与char的,windows应该也可以!但是我不知道您的编译器是否可以,
好的,您真是迅速呀。 我的编译器是 vs2019 和 mingw 8.1.0
from iguana.
Related Issues (20)
- 是否可以为枚举定义字符串值?比如将struct中的enum在json序列化中翻译为string HOT 4
- 最新是支持c++20,可以自定义支持c++17? HOT 7
- xml test fail:Uncaught (in promise) RuntimeError: memory access out of bounds HOT 3
- yaml解析字符串有注释时和`\t`抛异常 HOT 2
- json不支持std::variant类型吗?编译出错,能支持std::variant类型吗? HOT 3
- 当头文件#include <windows.h>在前面时,编译报错。 HOT 2
- error C7571: “iguana::char_t”: 已初始化变量模板 HOT 3
- unexpected exception HOT 2
- from_json unexpected exception
- yaml 序列的解析
- std::pair<std::string,Color> 序列化枚举不支持 HOT 9
- 请支持一下std::set HOT 3
- unexpected parse failed HOT 1
- json内嵌子对象,我如何将子对象转为对应的结构体? HOT 5
- 有没有打算支持继承类的智能指针呢? HOT 2
- json解析0.0为int HOT 6
- 对于union目前有好的处理办法吗? HOT 3
- REFLECTION 不支持添加std::variant<>类型的字段反射 HOT 12
- 在安卓平台上运行iguana::from_json(data, str);会报错: cannot locate symbol "__emutls_get_address" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iguana.