error "JSON syntax error" at position 15"{"name":"Jeremi <--Error-- "}"
I am trying to see why tdom is failing on this json snippet.
package req tdom
set x {{"name":"Jeremi"}}
dom parse -json $x
error "JSON syntax error" at position 15"{"name":"Jeremi <--Error-- "}"
If it doesn't get removed by the newsgroup editors, there is a weird character at the very end of x. It looks almost like "[]" but it is
not. When you edit it, it acts as if it has multiple characters in it.
Another problem is that tdom man page talks about a command "dom setResultEncoding ?encodingName?" but trying it results in an unknown command error.
I am trying to see why tdom is failing on this json snippet.
package req tdom
set x {{"name":"Jeremi^G"}}
dom parse -json $x
error "JSON syntax error" at position 15"{"name":"Jeremi^G <--Error-- "}"
Hello,
The unknown character is 007 or BELL.
Probably not allowed as a char in string.
Instead: \u0007
Gregor
On 12/16/2024 9:13 PM, greg wrote:
Hello,
The unknown character is 007 or BELL.
Probably not allowed as a char in string.
Instead: \u0007
Gregor
Thank you and Rich for the wonderful info and the code.
The json data is what I receive from an api. I first thought it had
to do with encoding issues. It happens frequently so I maybe I will
ask them to be more careful with their json data generation.
I am trying to see why tdom is failing on this json snippet.
package req tdom
set x {{"name":"Jeremi"}}
dom parse -json $x
error "JSON syntax error" at position 15"{"name":"Jeremi <--Error-- "}"
Another problem is that tdom man page talks about a command "dom setResultEncoding ?encodingName?" but trying it results in an unknown
command error.
You obviously use a (very) old tDOM version. The dom method setResultEncoding is a relict out of the times as tDOM still supported
Tcl 8.0 (and the functionality was only needed / useful if build/used
with Tcl 8.0).
The documentation and implementation of this method was removed with
tDOM 0.9.1 (more than six years ago). Most recent version is 0.9.5.
Thanks for the info. I am using version 0.9.5 I downloaded from its
official site some time ago. It comes with no documentation so I did an internet search. I guess that piece of info is from an outdated web
page obviously, which I kind of guessed.
Am 18.12.2024 um 20:57 schrieb saito:
Thanks for the info. I am using version 0.9.5 I downloaded from its
official site some time ago. It comes with no documentation so I did
an internet search. I guess that piece of info is from an outdated
web page obviously, which I kind of guessed.
http://tdom.org/index.html/doc/trunk/doc/index.html
proc chr c {
if {[string length $c] > 1 } {
error "chr: arg should be a single char"
}
set v 0
scan $c %c v
return $v
}
# Check character types and provide additional information
proc charInfo char {
if {[string is control $char]} {
return "control character"
} elseif {[string is space $char]} {
return "space character"
} elseif {[string is digit $char]} {
return "digit character"
} elseif {[string is lower $char]} {
return "lowercase alphabetic character"
} elseif {[string is upper $char]} {
return "uppercase alphabetic character"
} elseif {[string is punct $char]} {
return "punctuation character"
} elseif {[string is graph $char]} {
return "graphical character"
} elseif {[string is print $char]} {
return "printable character"
} else {
return "unknown character type"
}
}<snip>
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,029 |
Nodes: | 10 (0 / 10) |
Uptime: | 155:42:37 |
Calls: | 13,333 |
Calls today: | 3 |
Files: | 186,574 |
D/L today: |
4,829 files (1,287M bytes) |
Messages: | 3,355,917 |