Closed bastienird closed 1 year ago
This is likely a hack to force json accepting special characters, that are not allowed in JSON format. You need to escape these characters within the json:
Backspace to be replaced with \b
Form feed to be replaced with \f
Newline to be replaced with \n
Carriage return to be replaced with \r
Tab to be replaced with \t
Double quote to be replaced with \"
Backslash to be replaced with \
Tab could be different :
> library(jsonlite)
> txt_raw <- '
, ,""'
> toJSON(txt_raw, pretty = TRUE)
["\n, ,\"\""]
But IMO, it's better to have configuration in plain text than json. Then transfering to proper json is easy. PR from @BastienIRD raised this issue !
I summarized all special characters for JSON format, but not all are relevant here. The fact is that we should not have non standard json files. In this case backslash should just be escaped to make it work. That's the general practice recommended when dealing with JSON files
Le ven. 24 févr. 2023 à 09:27, Sylvain POULAIN @.***> a écrit :
Tab could be different :
library(jsonlite) txt_raw <- ' , ,""' toJSON(txt_raw, pretty = TRUE) ["\n, ,\"\""]
But IMO, it's better to have configuration in plain text than json. Then transfering to proper json is easy. PR from @BastienIRD https://github.com/BastienIRD raised this issue !
— Reply to this email directly, view it on GitHub https://github.com/r-geoflow/geoflow/pull/314#issuecomment-1443115531, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKDK3FQL2XIE25P4TKJ6BTWZBWHBANCNFSM6AAAAAAVGSXQRA . You are receiving this because you commented.Message ID: @.***>
Just for my understanding, you mean this :
txt_raw <- '"start",
, ,"", "\", "end"'
Output from ""
and "\"
is similar:
> toJSON(txt_raw)
["\"start\",\n, ,\"\", \"\", \"end\""]
I will come with a test json asap, i need to check, but now i've no computer, mine crashed yesterday
Le ven. 24 févr. 2023 à 09:44, Sylvain POULAIN @.***> a écrit :
Just for my understanding, you mean this :
txt_raw <- '"start", , ,"", "\", "end"'
Output from "" and "" is similar:
toJSON(txt_raw) ["\"start\",\n, ,\"\", \"\", \"end\""]
— Reply to this email directly, view it on GitHub https://github.com/r-geoflow/geoflow/pull/314#issuecomment-1443163607, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKDK3CKBNRQSS7DR4SG4X3WZBYFRANCNFSM6AAAAAAVGSXQRA . You are receiving this because you commented.Message ID: @.***>
For a backslash character this means trying to put a double backslash instead
Le ven. 24 févr. 2023 à 09:47, Emmanuel Blondel @.***> a écrit :
I will come with a test json asap, i need to check, but now i've no computer, mine crashed yesterday
Le ven. 24 févr. 2023 à 09:44, Sylvain POULAIN @.***> a écrit :
Just for my understanding, you mean this :
txt_raw <- '"start", , ,"", "\", "end"'
Output from "" and "" is similar:
toJSON(txt_raw) ["\"start\",\n, ,\"\", \"\", \"end\""]
— Reply to this email directly, view it on GitHub https://github.com/r-geoflow/geoflow/pull/314#issuecomment-1443163607, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKDK3CKBNRQSS7DR4SG4X3WZBYFRANCNFSM6AAAAAAVGSXQRA . You are receiving this because you commented.Message ID: @.***>
This is likely a hack to force json accepting special characters, that are not allowed in JSON format. You need to escape these characters within the json:
Backspace to be replaced with \b
Form feed to be replaced with \f
Newline to be replaced with \n
Carriage return to be replaced with \r
Tab to be replaced with \t
Double quote to be replaced with \"
Backslash to be replaced with \
See this diagram from original JSON author Crockford and ECMA definition.
Any special character has to be prepended by a backslash. Note that JSON is necessarily double quoted, single quote is not allowed
example, for " \ " in password