【发布时间】:2014-03-11 00:52:43
【问题描述】:
我有一个json文件,内容如下:
"1034280": {
"transcript": ["1040560",
"Ok, so what Akanksha is saying is that..."],
"interaction": "Student Question"
},
"1041600": {
"transcript": ["1044860",
"this is also not correct because it will take some time."],
"explain": "Describing&Interpreting"
},
"1046800": {
"transcript": ["1050620",
"So, what you have to do is, what is the closest to the answer?"],
"question": "FocusingInformation"
},
我想提取转录句子并将它们连接起来。
例如。我希望输出为:
"Ok, so what Akanksha is saying is that..." "this is also not correct because it will take some time." "So, what you have to do is, what is the closest to the answer?"
【问题讨论】:
-
如果您必须为此使用 bash(最好切换到具有原生 JSON 解析器的语言),
jsawk是您的朋友。 -
+1 对查尔斯的评论:
ruby -rjson -e 'JSON.parse(STDIN.read).each_pair {|k,v| print %q{"%s" } % v["transcript"][1]}'有效,如果示例文本被调整为有效的 JSON。 -
您的
json无效。