Skip to content

Commit 2a1c73d

Browse files
committed
Don't put double quote except on string type
1 parent 1c98677 commit 2a1c73d

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

NppJSONViewer/NppJsonViewer/RapidJsonHandler.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bool RapidJsonHandler::Null()
1212
return false;
1313

1414
TreeNode *parent = m_NodeStack.top();
15-
HandleArray(parent, STR_NULL);
15+
HandleArray(parent, STR_NULL, false);
1616
return true;
1717
}
1818

@@ -22,7 +22,7 @@ bool RapidJsonHandler::Bool(bool b)
2222
return false;
2323

2424
TreeNode *parent = m_NodeStack.top();
25-
HandleArray(parent, b ? STR_TRUE : STR_FALSE);
25+
HandleArray(parent, b ? STR_TRUE : STR_FALSE, false);
2626
return true;
2727
}
2828

@@ -57,7 +57,7 @@ bool RapidJsonHandler::RawNumber(const Ch *str, unsigned /*length*/, bool /*copy
5757
return false;
5858

5959
TreeNode *parent = m_NodeStack.top();
60-
HandleArray(parent, str);
60+
HandleArray(parent, str, false);
6161
return true;
6262
}
6363

@@ -74,7 +74,7 @@ bool RapidJsonHandler::String(const Ch *str, unsigned /*length*/, bool /*copy*/)
7474
}
7575

7676
TreeNode *parent = m_NodeStack.top();
77-
HandleArray(parent, str);
77+
HandleArray(parent, str, true);
7878

7979
return true;
8080
}
@@ -193,7 +193,7 @@ bool RapidJsonHandler::EndArray(unsigned /*elementCount*/)
193193
return true;
194194
}
195195

196-
void RapidJsonHandler::HandleArray(TreeNode *node, const char *const str)
196+
void RapidJsonHandler::HandleArray(TreeNode *node, const char *const str, bool bQuote)
197197
{
198198
if (!node || !str)
199199
return;
@@ -211,6 +211,9 @@ void RapidJsonHandler::HandleArray(TreeNode *node, const char *const str)
211211
node->counter++;
212212
}
213213

214-
// insert
215-
m_dlg->InsertToTree(node->subRoot, node->node.key + " : \"" + node->node.value + "\"");
214+
// Insert item to tree
215+
if (bQuote)
216+
m_dlg->InsertToTree(node->subRoot, node->node.key + " : \"" + node->node.value + "\"");
217+
else
218+
m_dlg->InsertToTree(node->subRoot, node->node.key + " : " + node->node.value);
216219
}

NppJSONViewer/NppJsonViewer/RapidJsonHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ class RapidJsonHandler : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
4848
bool EndArray(unsigned elementCount);
4949

5050
private:
51-
void HandleArray(TreeNode *node, const char *const str);
51+
void HandleArray(TreeNode *node, const char *const str, bool bQuote);
5252
};

0 commit comments

Comments
 (0)