I have some log files.i want to convert content of these files to json
format using python.required json format is
{
"content": {
"text" : // raw text to be split
},
"metadata";: {
...meta data fields, eg. hostname, logpath,
other fields passed from client...
}
}
i tried json
dump in python 2.7
but unexpected errors are coming..any suggestion will be great..
thanks..
error I got :
Traceback (most recent call last):
File "LogToJson.py", line 12,
in <module> f.write(json.dumps(json.loads(f1), indent=1))
File "/usr/lib/python2.7/json/__init__.py", line 338,
in loads return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366,
in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer
sample data:
Jan 27 10:46:57 sabya-ThinkPad-T420 NetworkManager[1462]:
<info> address 9.124.29.61
Jan 27 10:46:57 sabya-ThinkPad-T420 NetworkManager[1462]:
<info> prefix 24 (255.255.255.0)
Jan 27 10:46:57 sabya-ThinkPad-T420 NetworkManager[1462]:
<info> gateway 9.124.29.1