Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove invalid \n in JSON #43

Closed
katrinleinweber opened this issue Mar 20, 2018 · 7 comments
Closed

Remove invalid \n in JSON #43

katrinleinweber opened this issue Mar 20, 2018 · 7 comments
Assignees
Labels

Comments

@katrinleinweber
Copy link
Collaborator

katrinleinweber commented Mar 20, 2018

While implementing #31 and switching from rjson to jsonlite I noticed that some fields contain a insufficiently escaped \ns. This results in lexical error: invalid character inside string..

@ceb15: Please consider ensuring that those are escaped as \\n already BacDive or (I presume) during JSON serialisation.

screen shot 2018-03-20 at 11 00 02

I'll parse them away for now.

@katrinleinweber
Copy link
Collaborator Author

Ah, no, sorry! It might not be an issue in the BacDive data, but in the way R expects the escape sequences: jeroen/jsonlite#47. I wonder whether it might be possible to detect an R client, and then deliver \\n instead of \n dynamically?

@katrinleinweber
Copy link
Collaborator Author

Fixed by cae151d.

@katrinleinweber
Copy link
Collaborator Author

Whoa! The above dataset doesn't contain that sample any more:

screen shot 2018-07-31 at 12 58 54

@katrinleinweber
Copy link
Collaborator Author

gsub(
pattern = "[[:space:]]+",
replacement = " ",
perl = TRUE,
# Prevent "lexical error: invalid character inside string."
# https://github.com/jeroen/jsonlite/issues/47

is a bit stupid. There should be a specific purging of invalidly escaped characters, not of all space characters.

@katrinleinweber
Copy link
Collaborator Author

Since this changes the output datasets, it might as well be the reason to bump the semantic version to 1.0. #14 also supports this.

@katrinleinweber
Copy link
Collaborator Author

tested with retrieve_data("Bacillus"), which downloaded about 1.3k datasets without escaping errors.

@katrinleinweber
Copy link
Collaborator Author

No update to v1.0 after all, since some other kinks should be ironed out first (#68, #84, etc). v0.5 it is!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant