I have an addon that runs a command everytime I hit save.
I get the following error when I try to run a batch file on save:
The command autopush.bat was not found, but does exist in the current
location. Windows PowerShell does not load commands from the current
location by default. If you trust this command, instead type:
".\autopush.bat". See "get-help about_Command_Precedence" for more
details.
My settings.json file:
{
"saveAndRun": {
"commands": [
{
"match": ".*",
"cmd": "autopush.bat",
"useShortcut": false,
"silent": false
}
]
}
}
I am not sure about how I can add a dot and backslash to "autostart.bat"
I tried with ".\b autostart.bat" but it didn't work.
My bad, I used the wrong escape character. I had to use .\\autostart.bat as described here: How to escape special characters in building a JSON string?
\b Backspace (ascii code 08)
\f Form feed (ascii code 0C)
\n New line
\r Carriage return
\t Tab
\" Double quote
\\ Backslash character
Related
Good Afternoon all,
I am presenting the following problem.
new_ecdsa_config.json looks something like:
{
"certificate": "value long string
multine"
}
When I run the github action for reading the value
- name: Add new ECDSA to Organization
run: |
cat new_ecdsa_config.json | jq '.'
I get the following error:
parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 26, column 53
Error: Process completed with exit code 4.
Any ideas??
When you described the problem on github, you gave this as the example:
{
"certificate": "value long string
multine"
}
As the error message says, that is not valid JSON. (You can double-check this at jsonlint.com if you like.)
If you want the JSON representation of a multiline string, you'd have to escape the newline, e.g. along the lines of:
{
"certificate": "value long string\nmultiline"
}
Im trying to push a json file to BQ via bqcmd which contains special chars such as ü but tis failing. Ive tried differnt encoding etc. nothing workign except removing the chars
{
"productName": "soft drüum",
"Category": "xxxxxxx",
"subCategory": "Sun & Tan",
"subSubCategory": "Sun",
"productType": "Standard",
"brandName": "soft drüum",
"quantity": 1
}
Json File was successful until introduction of special chars
BQ command:
bq load --autodetect=true --time_partitioning_field date
--source_format NEWLINE_DELIMITED_JSON Data.products D:\XXXX\xx\products.json
I would check to make sure that you have your json saved as new line delimited. In your example, the trailing comma is not valid in New Line Delimited JSON.
I was able to then upload these special characters via this command:
bq load --project_id=${project_id} --source_format NEWLINE_DELIMITED_JSON --autodetect ${database}.${table} ${nldjson_filename}
I have some info store in a MySQL database, something like: AHmmgZq\n/+AH+G4
We get that using an API, so when I read it in my python I get: AHmmgZq\\n/+AH+G4 The backslash is doubled!
Now I need to put that into a JSON file, how can I remove the extra backslash?
EDIT: let me show my full code:
json_dict = {
"private_key": "AHmmgZq\\n/+AH+G4"
}
print(json_dict)
print(json_dict['private_key'])
with open(file_name, "w", encoding="utf-8") as f:
json.dump(json_dict, f, ensure_ascii=False, indent=2)
In the first print I have the doubled backslash, but in the second one there's only one. When I dump it to the json file it gives me doubled.
"AHmmgZq\\n/+AH+G4" in python is equivalent to the literal string "AHmmgZq\n/+AH+G4". print("AHmmgZq\\n/+AH+G4") => "AHmmgZq\n/+AH+G4"
\n is a new line character in python. So to represent \n literally it needs to be escaped with a \. I would first try to convert to json as is and see if that works.
Otherwise for removing extra backslashs:
string_to_json.replace("\\\\","\\")
Remember that \\ = escaped \ = \
But in the above string that will not help you, because python reads "AHmmgZq\\n/+AH+G4" as "AHmmgZq\n/+AH+G4" and so finds no double backslash.
What solved my problem was this:
string_to_json.replace("\\n","\n")
Thanks to everybody!
I have the following grok pattern that works in Logstash and in the Grok debugger in Kibana.
\[%{TIMESTAMP_ISO8601:req_time}\] %{IP:client_ip} (?:%{IP:forwarded_for}|\(-\)) (?:%{QS:request}|-) %{NUMBER:response_code:int} %{WORD}:%{NUMBER:request_length:int} %{WORD}:%{NUMBER:body_bytes_sent:int} %{WORD}:(?:%{QS:http_referer}|-) %{WORD}:(?:%{QS:http_user_agent}|-) (%{WORD}:(\")?(%{NUMBER:request_time:float})(\")?)?"
I am trying to create a new ingest pipeline via the PUT method, but I get an error that contains:
"type": "parse_exception",
"reason": "Failed to parse content to map",
"caused_by": {
"type": "i_o_exception",
"reason": "Unrecognized character escape '[' (code 91)\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper#61326735; line: 7, column: 25]"
}
Elasticsearch requires that grok patterns used in pipelines submitted using the PUT method are properly escaped JSON, while Logstash patterns use different escaping.
That includes preceding brackets with double backslashes (\\[) and double quotes with triple backslashes (\\\"). The working pattern (after running through a JSON escaping tool) is:
\\[%{TIMESTAMP_ISO8601:req_time}\\] %{IP:client_ip} (?:%{IP:forwarded_for}|\\(-\\)) (?:%{QS:request}|-) %{NUMBER:response_code:int} %{WORD}:%{NUMBER:request_length:int} %{WORD}:%{NUMBER:body_bytes_sent:int} %{WORD}:(?:%{QS:http_referer}|-) %{WORD}:(?:%{QS:http_user_agent}|-) (%{WORD}:(\\\")?(%{NUMBER:request_time:float})(\\\")?)?
When trying to pass the user defined value to the body content, I am getting error "message": "Bad JSON escape sequence: \S. ---- \r\nUnexpected character encountered while parsing value".
When passing complete raw payload through body data, I am not getting this error.
With User defined Variable,
"customerBillingAddress":"26 Chestnut St\Suite 2B\Andover, MA 01810",
convert as " "customerBillingAddress":"26 Chestnut St\Suite 2B\Andover, MA 01810","
"\" is throwing error.
When testing with raw data, I am getting as it is in the payload.
"customerBillingAddress":"26 Chestnut St\\Suite 2B\\Andover, MA 01810",
Please advise
You need to escape \ with \\ and double quote " with \" as per JSON format guideline. Here I think you only need to escape \ in your JSON payload like below .
"customerBillingAddress":"26 Chestnut St\\Suite 2B\\Andover, MA 01810"
You need to escape the following characters in JSON:
\b Backspace (ascii code 08)
\f Form feed (ascii code 0C)
\n New line
\r Carriage return
\t Tab
\" Double quote
\\ Backslash character
In order to do this automatically you can use __groovy() function available since JMeter 3.1 like:
${__groovy(org.apache.commons.lang3.StringEscapeUtils.escapeJson(vars.get('json')),)}
Demo: