我希望能够解析日志文件中的JSON对象。但是,使用JSON解析器需要我的完整文件都是JSON格式,而这并不是我的情况。有没有办法可以逐行解析文件并获取JSON对象呢? 以下是我的日志文件格式:
2015-10-19 11:24:35:701 INFO BrokerTcpClient:28 - Set destination
2015-10-19 11:24:35:929 DEBUG BrokerTcpClient:32 - received data: {type=data, payload={
"core" : [ {
"id" : {
"datatype" : "http://www.w3.org/2001/hk#long",
"type" : "gh",
"value" : "gh"
},
"entity" : {
"type" : "uri",
"value" : "http://fg.fg.com/ext/g/fg"
},
"Sno" : {
"type" : "literal",
"value" : "fg"
}]
2015-10-19 11:24:35:701 INFO BrokerTcpClient:28 - Set destination
2015-10-19 11:24:35:929 DEBUG BrokerTcpClient:32
"core" : [ {
"id" : {
"datatype" : "http://www.w3.org/2001/hk#long",
"type" : "gh",
"value" : "gh"
},
"entity" : {
"type" : "uri",
"value" : "http://fg.fg.com/ext/g/fg"
},
"Sno" : {
"type" : "literal",
"value" : "fg"
}]
请问有谁能帮我获取我的JSON对象。当我尝试解析一行JSON对象时,会抛出异常。