From 2e5e8bed3302a986a07239ae998622c135bd7f2a Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 12 Dec 2024 16:16:01 +0800 Subject: [PATCH] feat: add .natvis --- README.md | 4 ++++ README_en.md | 4 ++++ tools/meojson.natvis | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 tools/meojson.natvis diff --git a/README.md b/README.md index 9e2bc12..61de7fb 100644 --- a/README.md +++ b/README.md @@ -375,3 +375,7 @@ std::cout << value["名字"] << std::endl; // str = "value" std::string str = (std::string)value["key"][0]; ``` + +## 调试 + +如果您正在使用 Visual Studio,并希望 `json::value` 在调试器中显示的更为直观,请为您的解决方案/项目添加 `tools/meojson.natvis`,详见 [将 .natvis 文件添加到 C++ 项目](https://learn.microsoft.com/zh-cn/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2022#add-a-natvis-file-to-a-c-project)。 diff --git a/README_en.md b/README_en.md index 435472b..b8d66b5 100644 --- a/README_en.md +++ b/README_en.md @@ -375,3 +375,7 @@ std::cout << value["名字"] << std::endl; // str = "value" std::string str = (std::string)value["key"][0]; ``` + +## Debug + +If you are using Visual Studio and want `json::value` to be more visible in the debugger, please add `tools/meojson.natvis` to your solution/project, ref to [Add a .natvis file to a C++ project](https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2022#add-a-natvis-file-to-a-c-project). diff --git a/tools/meojson.natvis b/tools/meojson.natvis new file mode 100644 index 0000000..0e8ec20 --- /dev/null +++ b/tools/meojson.natvis @@ -0,0 +1,26 @@ + + + + + {{ type={_type} str={to_string()} }} + + _type + format(4) + _raw_data._Head + *_raw_data._Tail._Head + *_raw_data._Tail._Tail._Head + + + + {{ size={_array_data.size()} str={to_string()} }} + + _array_data + + + + {{ size={_object_data._Mypair._Myval2._Myval2._Mysize} str={to_string()} }} + + _object_data + + +