Skip to content

Commit addd5a5

Browse files
author
Kapil Ratnani
committed
fixed bug #3 - escaped double quotes - unescaping double qoutes in the string before display
1 parent 90c1f89 commit addd5a5

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

NppJSONViewer/JSONDialog.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ void JSONDialog::populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_
8181
{
8282
case JSON_STRING:
8383
/*
84-
if this is the leaf node show it in the same level as the parent.
85-
in other words, it shows a value with its key in a form "key":"value"
84+
insert the value with its key in a form "key":"value"
8685
*/
8786
if(json_root->child==NULL && json_root->parent->type!=JSON_ARRAY)
8887
{
@@ -94,7 +93,11 @@ void JSONDialog::populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_
9493
int len=strlen(json_root->parent->text)+3+strlen(json_root->text)+1;
9594
char *txt=new char[len];
9695
memset(txt, 0, len);
97-
sprintf(txt,"%s : %s",json_root->parent->text,json_root->text);
96+
char *unesc_text=json_unescape(json_root->text);
97+
char *unesc_parent_text=json_unescape(json_root->parent->text);
98+
sprintf(txt,"%s : %s",unesc_parent_text,unesc_text);
99+
free(unesc_text);
100+
free(unesc_parent_text);
98101

99102
len = strlen(txt) + 1;
100103
wchar_t *w_txt = new wchar_t[len];
@@ -107,14 +110,15 @@ void JSONDialog::populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_
107110
}
108111
}else
109112
{
110-
//not a leaf insert in to tree
111-
newItem=insertToTree(hWndDlg,tree_root,json_root->text);
113+
// it is an array element, insert directly
114+
char *unesc_elem=json_unescape(json_root->text);
115+
newItem=insertToTree(hWndDlg,tree_root,unesc_elem);
116+
free(unesc_elem);
112117
}
113118
break;
114119
case JSON_NUMBER:
115120
/*
116-
if this is the leaf node show it in the same level as the parent.
117-
in other words, it shows a value with its key in a form "key":"value"
121+
insert the value with its key in a form "key":"value"
118122
*/
119123
if(json_root->child==NULL && json_root->parent->type!=JSON_ARRAY)
120124
{
@@ -126,7 +130,9 @@ void JSONDialog::populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_
126130
int len=strlen(json_root->parent->text)+3+strlen(json_root->text)+1;
127131
char *txt=new char[len];
128132
memset(txt, 0, len);
129-
sprintf(txt,"%s : %s",json_root->parent->text,json_root->text);
133+
char *unesc_parent_text=json_unescape(json_root->parent->text);
134+
sprintf(txt,"%s : %s",unesc_parent_text,json_root->text);
135+
free(unesc_parent_text);
130136

131137
len = strlen(txt) + 1;
132138
wchar_t *w_txt = new wchar_t[len];
@@ -139,7 +145,7 @@ void JSONDialog::populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_
139145
}
140146
}else
141147
{
142-
//not a leaf insert in to tree
148+
// it is an array element, insert directly
143149
newItem=insertToTree(hWndDlg,tree_root,json_root->text);
144150
}
145151
break;
@@ -162,14 +168,13 @@ void JSONDialog::populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_
162168

163169
if (json_root->child != NULL)
164170
{
165-
json_t *ita, *itb;
171+
json_t *ita;
166172
ita = json_root->child;
167173

168174
while (ita != NULL)
169175
{
170176
populateTree(hWndDlg,newItem,ita, level + 1);
171-
itb = ita->next;
172-
ita = itb;
177+
ita = ita->next;
173178
}
174179
}
175180
}

README

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
=================
2-
JSONViewer 1.19
2+
JSONViewer 1.20
33
by Kapil Ratnani
44
=================
55

@@ -22,6 +22,11 @@ Rui Maciel for mjson library
2222
==================
2323
Latest Updates:
2424
==================
25+
----
26+
1.20
27+
----
28+
1. Fixed bug "#3 quoted doublequotes-Jan Huschauer"
29+
2530
----
2631
1.19
2732
----

0 commit comments

Comments
 (0)