@@ -264,21 +264,23 @@ void JsonViewDlg::SearchInTree()
264264 auto nodeVal = m_hTreeView->GetNodeValue (nextNode);
265265
266266 // Search in node value
267- if (nodeKey != nodeVal)
267+ // 1. If both key and value are not equal
268+ // 2. If both are euaal, but not all three (key, value and keyValue)
269+ // 3. If all three equal, but key does not start with '[' and end with ']'
270+
271+ bool shouldSearch = (nodeKey != nodeVal);
272+ shouldSearch |= (nodeKey == nodeVal && nodeKey != nodeText);
273+ shouldSearch |= (nodeKey == nodeVal && nodeKey == nodeText && !nodeKey.starts_with (L" [" ) && !nodeKey.ends_with (L" ]" ));
274+ if (shouldSearch)
268275 bFound = StringHelper::Contains (nodeVal, itemToSearch);
269276
270- // If both are euaal, but not all three
271- // { "[i]": "[i]"} => Search for '[i]'
272- //
273- if (!bFound && nodeKey == nodeVal && nodeKey != nodeText)
274- bFound = StringHelper::Contains (nodeVal, itemToSearch);
277+ // Search in Key if not found in value
278+ // 1. If key does not start with '[' and end with ']'
279+
280+ shouldSearch = (!nodeKey.starts_with (L" [" ) && !nodeKey.ends_with (L" ]" ));
281+ if (!bFound && shouldSearch)
282+ bFound = StringHelper::Contains (nodeKey, itemToSearch);
275283
276- // If all three are same, then key does not start with '[' and end with ']'
277- // "num": [12.148681171238422,42.835353759876654] => Search for 'num'
278- //
279- if (!bFound && nodeKey == nodeVal && nodeKey == nodeText && !nodeKey.starts_with (L" [" ) && !nodeKey.ends_with (L" ]" ))
280- bFound = StringHelper::Contains (nodeText, itemToSearch);
281-
282284 if (bFound)
283285 break ;
284286
0 commit comments