1

I'm looking for a natvis file for JsonCpp and I can't find any.

Does anyone know of such a file?

Motti
  • 110,860
  • 49
  • 189
  • 262

2 Answers2

1

Edit: I've added this file to the visualstudio-debugger repository on GitHub.

Edit2: Two other answers to this question have linked to other github repositories (which I haven't checked out). For some reason they were deleted by admins (I have no idea why) so here they are:


Since nobody came through with an answer (and some people think this is off topic on stackoverflow for some reason) I wrote my own, here it is. Use at your own risk.

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <!-- Json::Value - basic support -->
  <Type Name="Json::Value">
    <DisplayString Condition="type_ == 0">null</DisplayString>
    <DisplayString Condition="type_ == 1">{value_.int_}</DisplayString>
    <DisplayString Condition="type_ == 2">{value_.uint_}</DisplayString>
    <DisplayString Condition="type_ == 3">{value_.real_}</DisplayString>
    <DisplayString Condition="type_ == 4">{value_.string_,s8}</DisplayString>
    <DisplayString Condition="type_ == 5">{value_.bool_}</DisplayString>
    <DisplayString Condition="type_ == 6">array ({value_.map_-&gt;_Mysize})</DisplayString>
    <DisplayString Condition="type_ == 7">object ({value_.map_-&gt;_Mysize})</DisplayString>
    <DisplayString >Unknown Value type!</DisplayString>
    <StringView Condition="type_ == 4">value_.string_,s8</StringView>
    <Expand>
      <ExpandedItem Condition="type_ == 6">*(value_.map_)</ExpandedItem>
      <ExpandedItem Condition="type_ == 7">*(value_.map_)</ExpandedItem>
    </Expand>
  </Type>

  <!-- Key/value pairs - used as values for objects and arrays (in arrays the key is null so don't display it) -->
  <Type Name="std::pair&lt;Json::Value::CZString const ,Json::Value&gt;">
    <DisplayString Condition="first.cstr_ != nullptr">{first.cstr_,s8}: {second}</DisplayString>
    <DisplayString>{second}</DisplayString>
    <Expand>
      <Item Name="key" Condition="first.cstr_ != nullptr">first.cstr_</Item>
      <Item Name="value" Condition="first.cstr_ != nullptr">second</Item>
      <ExpandedItem>second</ExpandedItem>
    </Expand>
  </Type>
</AutoVisualizer>
Motti
  • 110,860
  • 49
  • 189
  • 262
1

Based on the (deleted) answer of Dmitry Yastrebkov I made the following one that seems to be working nicely for me:

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <Type Name="std::map&lt;*&gt;" IncludeView="jsoncpp">
    <Expand>
      <TreeItems>
        <Size>_Mypair._Myval2._Myval2._Mysize</Size>
        <HeadPointer>_Mypair._Myval2._Myval2._Myhead-&gt;_Parent</HeadPointer>
        <LeftPointer>_Left</LeftPointer>
        <RightPointer>_Right</RightPointer>
        <ValueNode Condition="_Isnil == 0 &amp;&amp; true" Name="{_Myval,view(jsonname)}">_Myval,view(jsoncpp)</ValueNode>
      </TreeItems>
    </Expand>
  </Type>

  <Type Name="std::pair&lt;*&gt;" IncludeView="jsonname">
    <DisplayString Condition="first.cstr_ == nullptr">[{first.index_}]</DisplayString>
    <DisplayString Condition="first.cstr_ != nullptr">{first.cstr_,s8}</DisplayString>
  </Type>

  <Type Name="std::pair&lt;*&gt;" IncludeView="jsoncpp">
    <DisplayString Condition="second.type_ == 0 &amp;&amp; true">null</DisplayString>
    <DisplayString Condition="second.type_ == 1 &amp;&amp; true">{second.value_.int_}</DisplayString>
    <DisplayString Condition="second.type_ == 2 &amp;&amp; true">{second.value_.uint_}</DisplayString>
    <DisplayString Condition="second.type_ == 3 &amp;&amp; true">{second.value_.real_}</DisplayString>
    <DisplayString Condition="second.type_ == 4 &amp;&amp; true">{second.value_.string_,s8}</DisplayString>
    <DisplayString Condition="second.type_ == 5 &amp;&amp; true">{second.value_.bool_}</DisplayString>
    <DisplayString Condition="second.type_ == 6 &amp;&amp; true">array({second.value_.map_-&gt;_Mypair._Myval2._Myval2._Mysize})</DisplayString>
    <DisplayString Condition="second.type_ == 7 &amp;&amp; true">object({second.value_.map_-&gt;_Mypair._Myval2._Myval2._Mysize})</DisplayString>
    <StringView Condition="second.type_ == 1 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
    <StringView Condition="second.type_ == 2 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
    <StringView Condition="second.type_ == 3 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
    <StringView Condition="second.type_ == 4 &amp;&amp; true">second.value_.string_,s8</StringView>
    <StringView Condition="second.type_ == 5 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
    <StringView Condition="second.type_ == 6 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
    <StringView Condition="second.type_ == 7 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
    <Expand>
      <ExpandedItem Condition="second.type_ == 6">*(second.value_.map_),view(jsoncpp)</ExpandedItem>
      <ExpandedItem Condition="second.type_ == 7">*(second.value_.map_),view(jsoncpp)</ExpandedItem>
    </Expand>
  </Type>

  <Type Name="Json::Value">
    <Expand>
      <ExpandedItem Condition="type_ == 6">*(value_.map_),view(jsoncpp)</ExpandedItem>
      <ExpandedItem Condition="type_ == 7">*(value_.map_),view(jsoncpp)</ExpandedItem>
    </Expand>
  </Type>
</AutoVisualizer>
Matzi
  • 13,770
  • 4
  • 33
  • 50