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

How to set stdout to not escape content? #120

Open
hw2499 opened this issue May 4, 2024 · 4 comments
Open

How to set stdout to not escape content? #120

hw2499 opened this issue May 4, 2024 · 4 comments

Comments

@hw2499
Copy link

hw2499 commented May 4, 2024

The JSON content includes BackSLASH
The following code
Stdout:=query NewOutput()
Csvq SetStdout (stdout)
Fmt Println ("stdout. String():", stdout String()
It was found that the output of stdout escaped/opt/, resulting in /opt /,
This is not the desired effect, what if it is set to incorrect/escaped?

@mithrandie
Copy link
Owner

Please provide more details on the following information.

  1. Codes for reproduction of the result, and its input data if necessary.
  2. The output result of executing that code.
  3. Desired output result.

@hw2499
Copy link
Author

hw2499 commented May 9, 2024

Thank you for your reply .

1. file content

key;value
MrLi; {path1:/usr/local/a}
MrAa; {path1:/usr/local/b}

2. code:

queryString := "" +
"SET @@IMPORT_FORMAT TO JSON;" +
"SET @@Format TO JSON;" +
"SET @@PRETTY_PRINT TO TRUE;" +
"SET @@delimiter TO ';';"

_, err = db.Exec(queryString)
if err != nil {
	fmt.Println("runtime fail:", err)
	 
}

stdout := query.NewOutput()
csvq.SetStdout(stdout)
queryString = "select * from `readme2.csv`"
_, err = db.Query(queryString)
if err != nil {
	fmt.Println("query fail:", err)
 
}
fmt.Println("stdout.String():", stdout.String())

3. output result

stdout.String(): [
  {
    "key": "MrLi",
    "value": " {path1:\/usr\/local\/a}"
  },
  {
    "key": "MrAa",
    "value": " {path1:\/usr\/local\/b}"
  }
]

4. Desired output result.

[
{
"key": "MrLi",
"value": " {path1:/usr/local/a}"
},
{
"key": "MrAa",
"value": " {path1:/usr/local/b}"
}
]

@mithrandie
Copy link
Owner

Thank you, I understand what you want.

According to RFC8259, solidus (U+002F) is not MUST be escaped, but it is listed as a character to be escaped, so csvq is also escapes it in the output.
It can be read with or without escaping when reading, but currently there is no option to exclude escaping of this character in the output.

@hw2499
Copy link
Author

hw2499 commented May 13, 2024

Thank you for your reply. I hope to have time to implement this feature in the future

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

No branches or pull requests

2 participants