我正在尝试转义json文件中的双引号。
但是只要到#!/bin/sh
#exit 1
/bin/false
,JsonOutput.toJson
就会重新出现。
这是我的代码:
\
这是我的文件:
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
def script = new File('${file}')
def content = new JsonSlurper().parseText(script.text)
def text = JsonOutput.toJson(content)
预期输出:
{
"admin_id": "admin_user",
"admin_pwd": "admin_password",
"commands": [
"command one",
"command two",
"command \"three\" with double quotes",
"command four"
]
}
转义字符{"admin_id": "admin_user","admin_pwd": "admin_password","commands":["command one","command two","command "three" with double quotes","command four"]}
不应出现在输出中。