@@ -156,10 +156,78 @@ void JSONDialog::populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_
156
156
newItem=insertToTree (hWndDlg,tree_root," Array" );
157
157
break ;
158
158
case JSON_TRUE:
159
- newItem=insertToTree (hWndDlg,tree_root," True" );
159
+ /*
160
+ insert the value with its key in a form "key":"value"
161
+ */
162
+ if (json_root->child ==NULL && json_root->parent ->type !=JSON_ARRAY)
163
+ {
164
+ TVITEM t;
165
+ t.hItem =tree_root;
166
+ t.mask =TVIF_HANDLE;
167
+ if (SendDlgItemMessage (hWndDlg,IDC_TREE1,TVM_GETITEM,0 ,(LPARAM)&t))
168
+ {
169
+ int len=strlen (json_root->parent ->text )+3 +strlen (json_root->text )+1 ;
170
+ char *txt=new char [len];
171
+ memset (txt, 0 , len);
172
+ char *unesc_text=json_unescape (" True" );
173
+ char *unesc_parent_text=json_unescape (json_root->parent ->text );
174
+ sprintf (txt," %s : %s" ,unesc_parent_text,unesc_text);
175
+ free (unesc_text);
176
+ free (unesc_parent_text);
177
+
178
+ len = strlen (txt) + 1 ;
179
+ wchar_t *w_txt = new wchar_t [len];
180
+ memset (w_txt, 0 , len);
181
+ MultiByteToWideChar (CP_UTF8, NULL , txt, -1 , w_txt, len);
182
+
183
+ t.pszText =w_txt;
184
+ t.mask =TVIF_TEXT;
185
+ ::SendDlgItemMessage (hWndDlg,IDC_TREE1,TVM_SETITEM,0 ,(LPARAM)&t);
186
+ }
187
+ }else
188
+ {
189
+ // it is an array element, insert directly
190
+ char *unesc_elem=json_unescape (json_root->text );
191
+ newItem=insertToTree (hWndDlg,tree_root,unesc_elem);
192
+ free (unesc_elem);
193
+ }
160
194
break ;
161
195
case JSON_FALSE:
162
- newItem=insertToTree (hWndDlg,tree_root," False" );
196
+ /*
197
+ insert the value with its key in a form "key":"value"
198
+ */
199
+ if (json_root->child ==NULL && json_root->parent ->type !=JSON_ARRAY)
200
+ {
201
+ TVITEM t;
202
+ t.hItem =tree_root;
203
+ t.mask =TVIF_HANDLE;
204
+ if (SendDlgItemMessage (hWndDlg,IDC_TREE1,TVM_GETITEM,0 ,(LPARAM)&t))
205
+ {
206
+ int len=strlen (json_root->parent ->text )+3 +strlen (json_root->text )+1 ;
207
+ char *txt=new char [len];
208
+ memset (txt, 0 , len);
209
+ char *unesc_text=json_unescape (" False" );
210
+ char *unesc_parent_text=json_unescape (json_root->parent ->text );
211
+ sprintf (txt," %s : %s" ,unesc_parent_text,unesc_text);
212
+ free (unesc_text);
213
+ free (unesc_parent_text);
214
+
215
+ len = strlen (txt) + 1 ;
216
+ wchar_t *w_txt = new wchar_t [len];
217
+ memset (w_txt, 0 , len);
218
+ MultiByteToWideChar (CP_UTF8, NULL , txt, -1 , w_txt, len);
219
+
220
+ t.pszText =w_txt;
221
+ t.mask =TVIF_TEXT;
222
+ ::SendDlgItemMessage (hWndDlg,IDC_TREE1,TVM_SETITEM,0 ,(LPARAM)&t);
223
+ }
224
+ }else
225
+ {
226
+ // it is an array element, insert directly
227
+ char *unesc_elem=json_unescape (json_root->text );
228
+ newItem=insertToTree (hWndDlg,tree_root,unesc_elem);
229
+ free (unesc_elem);
230
+ }
163
231
break ;
164
232
case JSON_NULL:
165
233
newItem=insertToTree (hWndDlg,tree_root," null" );
0 commit comments