First of all, I have to say that the readme.txt that came with Xidel zip file was ....... extensive.
So extensive that I couldn't find what I was actually after.
I'm running Xidel under Windows, and would like to call it in a simple way so that it checks whether the JSON code in the file is valid or not.
I tried the following
which worked fine inasmuch as xidel_output.json was "pretty formatted"
However, when I deliberately introduced an error into the JSON input file, xidel_output.txt was empty (as expected) but I also received all this verbage
Error:
jerr:JNDY0021: value not allowed at (tkCurlyBraceOpen) in {
Possible backtrace:
$00538A95: perhaps Q{http://jsoniq.org/functions}object + 3541 ? but unlikely
$004360E1: perhaps ? ? but unlikely
$00436176: perhaps ? ? but unlikely
$00437DAF: perhaps ? ? but unlikely
$00435544: perhaps ? ? but unlikely
$00435090: perhaps ? ? but unlikely
$0043F2B0: perhaps ? ? but unlikely
Call xidel with --trace-stack to get an actual backtrace
How do I redirect this to a NUL (or whatever it's called). I tried
This is more of a cmd question than a question about xidel, but no matter.
You're probably looking for -e "$json" 2>NUL.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2021-10-08
Reino. Sorry to have been so slow in acknowledging your answer (which did the trick for me). I think I had a blank after the 2> (either that or 2 >), can'r remember. Be that as it may, the final line I ran was
First of all, I have to say that the readme.txt that came with Xidel zip file was ....... extensive.
So extensive that I couldn't find what I was actually after.
I'm running Xidel under Windows, and would like to call it in a simple way so that it checks whether the JSON code in the file is valid or not.
I tried the following
"h:\xidel\xidel.exe" -s jpb172_swagger.json -e "$json" > xidel_output.json
which worked fine inasmuch as xidel_output.json was "pretty formatted"
However, when I deliberately introduced an error into the JSON input file, xidel_output.txt was empty (as expected) but I also received all this verbage
How do I redirect this to a NUL (or whatever it's called). I tried
"h:\xidel\xidel.exe" -s jpb172_swagger.json -e "$json" > xidelt_output.json >1 error_results
but that didn't seem to help. Any suggestions ?
Hello Michael,
This is more of a
cmd
question than a question aboutxidel
, but no matter.You're probably looking for
-e "$json" 2>NUL
.Reino. Sorry to have been so slow in acknowledging your answer (which did the trick for me). I think I had a blank after the 2> (either that or 2 >), can'r remember. Be that as it may, the final line I ran was
xidel_exe' -s input_file_to_check -e "$json" 1>NUL 2>dummy_output_file
If dummy_output_file is empty, then the input file was well-.formed.
Thanks again (and apologies again)
Michael
It does not really work.
If you have an invalid JSON like
{"a": 1, }
or{"a": 0001 }
, it is also loadedYou need the --input-format json-strict option to actually check the validity
Thank you for your suggestion. Just so we're on the same page, is this what you meant?
More like this:
"H:\Xidel\Xidel.exe" --input-format json-strict -s "H:\ICA\PRIV.JSON\JSON_FORMATTED\JPB113_SCHEMA_REQUEST.JSON" -e "$json" 1>NUL 2>"H:\A_MS_exe\json_format_results.txt"
And this would be faster:
"H:\Xidel\Xidel.exe" --input-format json-strict -s "H:\ICA\PRIV.JSON\JSON_FORMATTED\JPB113_SCHEMA_REQUEST.JSON" -e "count($json)" 1>NUL 2>"H:\A_MS_exe\json_format_results.txt"
Thank you. I implemented your second suggestion.