使用 awk 将双引号替换为单引号
BEGIN {
q = "\""
FS = OFS = q ", " q
}
{
split($1, arr, ": " q)
for(i in arr ) {
if(arr[i] == "name") {
gsub(q, "'", arr[i+1])
# print arr[1] ": " q arr[2], $2, $3
}
}
}
我有一个json文件,一些数据如下:
{"last_modified": {"type": "/type/datetime", "value": "2008-04-01T03:28:50.625462"}, "type": {"key": "/type/author"}, "name": "National Research Council. Committee on the Scientific and Technologic Base of Puerto Rico"s Economy.", "key": "/authors/OL2108538A", "revision": 1}
名称的值有双引号,我只想将双引号替换为单引号,而不是全部双引号,请告诉我如何修复它?
BEGIN {
q = "\""
FS = OFS = q ", " q
}
{
split($1, arr, ": " q)
for(i in arr ) {
if(arr[i] == "name") {
gsub(q, "'", arr[i+1])
# print arr[1] ": " q arr[2], $2, $3
}
}
}
I have a json file, some data like this:
{"last_modified": {"type": "/type/datetime", "value": "2008-04-01T03:28:50.625462"}, "type": {"key": "/type/author"}, "name": "National Research Council. Committee on the Scientific and Technologic Base of Puerto Rico"s Economy.", "key": "/authors/OL2108538A", "revision": 1}
The name's value have a double quote, I only want to replace the double quote to single quote , not the all double quote, please tell me how to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)