Suppose I have a JSON object:
obj= [{"name":"Era", "age":45, "sex":"female", "id":2545}
{"name":"Patrick", "age":35, "sex":"male", "id":2546}
{"name":"Elina", "age":40, "sex":"female", "id":2547}
{"name":"Reg", "age":47, "sex":"male", "id":2548}]
I want to make a (key,value) RDD from this data by only using the 'id' and the 'name' ('id' being the key in RDD). I tried the solution given in this link but getting the following error:
AttributeError: 'str' object has no attribute 'get'
To explain more here is my code-
for key in obj:
my_dict={}
my_dict['id']=key.get('id')
my_dict['name']=key.get('name')
result.append(my_dict)
I hope to get any help for this part so that I can go for the second part i.e. to make an rdd from it.