MCPcopy Create free account
hub / github.com/NPP-JSONViewer/JSON-Viewer / ValidateJson

Method ValidateJson

src/NppJsonViewer/JsonViewDlg.cpp:302–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302void JsonViewDlg::ValidateJson()
303{
304 UpdateTitle();
305
306 const auto selectedData = m_pEditor->GetJsonText();
307 const auto selectedText = IsSelectionValidJson(selectedData);
308
309 if (!selectedText.has_value() || selectedText.value().empty())
310 {
311 const std::wstring msg = IsMultiSelection(selectedData) ? JSON_ERR_MULTI_SELECTION : JSON_ERR_PARSE;
312 ShowMessage(JSON_INFO_TITLE, msg, MB_OK | MB_ICONINFORMATION);
313 return;
314 }
315
316 Result res = JsonHandler(m_pSetting->parseOptions).ValidateJson(selectedText.value());
317
318 if (res.success)
319 {
320 ShowMessage(JSON_INFO_TITLE, JSON_ERR_VALIDATE_SUCCESS, MB_OK | MB_ICONINFORMATION);
321 }
322 else
323 {
324 if (CheckForTokenUndefined(JsonViewDlg::eMethod::ValidateJson, selectedText.value(), res, NULL))
325 {
326 ShowMessage(JSON_INFO_TITLE, JSON_ERR_VALIDATE_SUCCESS, MB_OK | MB_ICONINFORMATION);
327 return;
328 }
329
330 ReportError(res);
331 }
332
333 DrawJsonTree();
334}
335
336void JsonViewDlg::DrawJsonTree()
337{

Callers 2

TEST_FFunction · 0.45

Calls 2

JsonHandlerClass · 0.85
GetJsonTextMethod · 0.80

Tested by 1

TEST_FFunction · 0.36