Reputation: 493
I got a task to get to find out ER from json files this is the one record
{ "__v" : 0, "_id" : ObjectId( "52210bf6880b9f0200000003" ), "email" : "", "emailFrequency" : "instant", "feedbackRating" : 0, "field_aboutMe" : "On Fridays I like to eat apples.", "field_contact" : "[email protected]", "field_intro" : "Sparkboard bug-fixer. Co-founded Hacking Health, Bodo Wellness, and BrainTripping.", "first_time" : false, "hash" : "", "name" : "Matt Huebert", "picture" : "https://www.ssss.com", "ready" : true, "roles" : [ "admin" ], "email" : "", "tags" : [ "Developer", "Designer", "Mentor" ], "updatedAt" : Date( 1384115378947 ), "votesByDomain" : { "sadsard-com" : "525eadf50f13910200000004" } }
after searching i found out it has something to do with MongoDB . I need to parse this data to find out Entities in it . when i check its validation its not a valid json as its been generated by mongo db . Please any body have any idea ?
Ive tried this as well
$data = file_get_contents('json/users.json');
bson_decode($data);
tried json_decode as well its also not working and returning NULL
I get this error while trying to bson_decode
Fatal error: Uncaught exception 'MongoException' with message 'type 0x5f not supported
Upvotes: 0
Views: 300
Reputation: 151112
Not sure what has dumped this into your json file, possibly from stdout of mongo shell, But this part is the problem:
ObjectId( "52210bf6880b9f0200000003" )
You need to remove the Wrapping "ObjectId(" and closing brace ")" in order to make each line valid JSON. Once that is filtered you are left with valid JSON.
If you know who is providing you with these files, and cannot use the mongodb datasource directly, then ask them to please use mongoexport, which will at least give you valid JSON from the start.
Upvotes: 1