I am trying to read a file which has tabs and newline etc and the data is JSON format.
When I read it using file.read()
/readlines()
etc, all the newlines and tabs are also read.
I have tried rstrip()
, split etc but in vain, maybe I am missing some thing:
Here is essentially what I am doing:
f = open('/path/to/file.txt')
line = f.readlines()
line.split('\n')
This is the data (including the raw tabs, hence the poor formatting):
{
"foo": [ {
"id1" : "1",
"blah": "blah blah",
"id2" : "5885221122",
"bar" : [
{
"name" : "Joe JJ",
"info": [ {
"custid": "SSN",
"type" : "String", } ]
} ] } ] }
I was wondering if we can ignore it elegantly.
Also hoping to use json.dumps()