You can use @sln JSON Perl/PCRE regex functions to validate and error check.
See this link for several practical usagge examples to query and validate JSON,
and for a full explanation of the several functions available :
https://stackoverflow.com/a/79785886/15577665
json_regexp = paste0(
"(?x) \n",
" \n",
" # JSON recursion functions by @sln \n",
" \n",
" (?: \n",
" (?: # Valid JSON Object or Array \n",
" (?&V_Obj) \n",
" | (?&V_Ary) \n",
" ) \n",
" | # or, \n",
" (?<Invalid> # (1), Invalid JSON - Find the error \n",
" (?&Er_Obj) \n",
" | (?&Er_Ary) \n",
" ) \n",
" ) \n",
" \n",
" \n",
" (?(DEFINE)(?<Sep_Ary>\s*(?:,(?!\s*[}\]])|(?=\])))(?<Sep_Obj>\s*(?:,(?!\s*[}\]])|(?=})))(?<Er_Obj>(?>{(?:\s*(?&Str)(?:\s*:(?:\s*(?:(?&Er_Value)|(?<Er_Ary>\[(?:\s*(?:(?&Er_Value)|(?&Er_Ary)|(?&Er_Obj))(?:(?&Sep_Ary)|(*ACCEPT)))*(?:\s*\]|(*ACCEPT)))|(?&Er_Obj))(?:(?&Sep_Obj)|(*ACCEPT))|(*ACCEPT))|(*ACCEPT)))*(?:\s*}|(*ACCEPT))))(?<Er_Value>(?>(?&Numb)|(?>true|false|null)|(?&Str)))(?<Str>(?>"[^\\"]*(?:\\[\s\S][^\\"]*)*"))(?<Numb>(?>[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|(?:[eE][+-]?\d+)))(?<V_KeyVal>(?>\s*(?&Str)\s*:\s*(?&V_Value)\s*))(?<V_Value>(?>(?&Numb)|(?>true|false|null)|(?&Str)|(?&V_Obj)|(?&V_Ary)))(?<V_Ary>\[(?>\s*(?&V_Value)(?&Sep_Ary))*\s*\])(?<V_Obj>{(?>(?&V_KeyVal)(?&Sep_Obj))*\s*})) \n"
)