0
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文件,一些數據是這樣的:使用awk替換雙引號單引號
{"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}
名字的價值有一個雙引號,我只是想更換雙引號單報價,而不是所有雙引號,請告訴我如何解決它?
在Python或Perl(或獨立版本)中使用適當的JSON解析器可能會更好。 – 2010-08-06 14:57:41
[需要幫助! sed或awk如何替換文本](http://stackoverflow.com/questions/3422103/need-help-sed-or-awk-how-to-replace-text) – 2010-08-06 15:00:18