'JSON reader was expecting a name but found ':'. in Mongodb Java
I am storing my data from external file to mongodb in localhost. it's quite huge dataset of volume 1.70GB with ~10 million tweets. While importing from file to mongodb it shows me the error "JSON reader was expecting a name but found ':'" I dint have any error on previous files. But this I cant figure it out. The data is just a real time collection of tweets from streaming API in a json format.
BufferedReader br = new BufferedReader(new FileReader(file));
int counter = 0;
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
Document old_status = Document.parse(line);
// If it is a deleted tweet, then continue
if (old_status.containsKey("delete")) {
continue;
}
//populate original tweets
Document original_status = new Document();
if(line.contains("retweeted_status")){
Document retweets = (Document)old_status.get("retweeted_status");
original_status.append("status",retweets.get("text"));
original_status.append("Likes",retweets.getInteger("favorite_count"));}}
its a sample code for importing data from file to mongo collection. Help me to solve this. I really stuck in this place and it takes my time. Thanks in advance.
Solution 1:[1]
Late to the party, and also a little unrelated to this specific question, but google brought me here so going to leave an answer.
I got this error when I was trying to parse a mongodb document that was converted to JSON in Scala. Make sure that the variable's you're trying to parse are actually in the JSON you're parsing if it is a strict parsing.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nick Brady |