I have a json file with 15000+ lines that looks like this;
{
"address": [
"user address"
]
}{
"purchase": [
"details"
]
}{
"info1": [
"some information",
"other information",
"more information"
],
"info2": [
"something else"
]
}
I want to do something like:
f = open('my_file.json',)
data = json.load(f)
print(data[2])
In which index[2] would print everything between the last set of curly brackets so:
{
"info1": [
"some information",
"other information",
"more information"
],
"info2": [
"something else"
]
}
However I get error: raise JSONDecodeError("Extra data", s, end)
It works if I make it a string, something like: my_str = '[{"address": "user address"}, {"info1": "some information", "more information"}]' print(my_str[2])
Is it possible to read json file as above and print [2]?
Based on below comment, if I do something like this:
with open('my_file.json', 'r') as f:
my_list = list(f)
values_list = list(my_list)
a_value = values_list
print(a_value[10])
It prints "some information".