Unable to upload a JSON file to MongoDB

While using RockMongo in Openshift to import a json file into a MongoDB database, I came across an issue. The json was exported directly from another MongoDB without any modifications. Here is a snippet of the json data:

{ "_id" : "10352",
 "author" : "8988607", 
"country" : "...",
 "views" : 1716,
 "title" : "...", 
"comments" : 1, 
"likes" : 28, 
"text" : "...", 
"date" : { "$date" : 1278070740000 }, 
"approved" : "8480596" }

The error message received states:

exception: field names cannot start with $ [$date] at src/mongo/shell/collection.js:147

Since the json was directly exported from a different MongoDB, how can this problem be resolved now?

Answer №1

My team encountered a similar issue and our database administrator replaced the dollar sign with \uFF04, which resolved the problem for us.

Answer №2

Instead of standard JSON, MongoDB utilizes its own Extended JSON format. This could result in mismatches when using Rockmongo, which likely employs a standard JSON parser.

Have you tried utilizing the mongoimport application provided? To include all extended types, make sure to use version 2.4.0 or higher as mentioned in SERVER-5675

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unleashing the power of simultaneous JSON file openings and independent data

Recently started working with python and json. I'm trying to figure out how to open multiple json files using the "with open" statement, and then read each one individually. Here's the code I have so far: def read_json_files(filenames): data ...

Is express-jwt assigning the user object to req.user._doc, as opposed to just req.user?

Previously, I have utilized the npm package express-jwt for effortless JWT signing and decoding. Typically (and as per the documentation), it decodes the token in a request, extracts the user object payload, and assigns it to req.user. However, this time a ...

"Unraveling the mystery: Deserializing unidentified properties using JSON-B

Is there a way to deserialize the JSON data with dynamically generated numeric keys into a Map using Quarkus' JSON-B implementation? The challenge lies in dealing with unknown properties and mapping them to a Map<Long, MyObject> without manually ...

Is there a recursive method to verify the folder name for each aggregate?

Consider the scenario with these sample documents: (parent_id: null denotes items located at root directory) {"_id":"a", "name":"Pictures", "parent_id": null, "type": "folder"} {"_ ...

Unraveling JSON data in AngularJS

After receiving a response from an OData service in JSON format, the data looks like this: [ { "id":1, "ProductName":"Surface Pro 2" }, { "id":2, "ProductName":"iPad" }, ] When att ...

Struggling with handling white spaces during the transfer of JSON data to Python

As a high school math teacher, I am venturing into the world of programming to enhance my skills. Please bear with me if some of my terminology is not quite accurate. Currently, I am facing an issue with transferring CSV data collected from users to a SQL ...

Unable to convert JSON data to char array due to a NumberFormatException while using editText

I am attempting to parse JSON on Android, and after parsing the JSON, I want to convert the inputted ID in Edittext to a char array. However, I am encountering a NumberFormatException. I don't think this is a silly question, but where could the prob ...

Comparing JSON files in JavaScript to identify and extract only the new objects

I need a way to identify and output the newly added objects from two JSON files based on their "Id" values. It's important for me to disregard changes in object positions within the files and also ignore specific key-value changes, like Greg's ag ...

Updating multiple collections at once in mongoDB with a single request: A step-by-step guide

I am currently working on a route in Express and Mongoose that updates 2 collections within one route. The updates are successful and can be seen in MongoDb, but after the request is made, the server crashes with the error code: 'ERR_HTTP_HEADERS_SENT ...

Receiving an incorrect UTF-8 sequence in the JSON input

I currently have an ec2 server running with PHP version 5.3, hosting 2 virtual hosts: one for development and one for live production. Interestingly, on the development host, if someone uploads a file containing invalid UTF-8 characters, it simply ignores ...

I am unable to retrieve the req.body or the body content in a post request. The code functions properly when using hardcoded JSON

Take a look at my code: controllers/task When testing in Postman, I'm getting validation errors I've even tried using a body parser, but it doesn't seem to be working either. Check out app.js ...

Strange issue encountered when utilizing Worklight along with XSL transformation on a JSON response

I'm facing an unusual issue that I can't seem to resolve. Here is an example of a JSON response that I am dealing with. "values": [ { "time": "2014-02-26T09:01:00+01:00", "data": [ "A", "B" ] }, // additional objec ...

Stop jQuery from adding duplicate values to a table

When I make an AJAX call using jQuery and PHP to receive JSON response, I am encountering a problem with duplicate values. The code is functioning correctly, but when selecting an option from the drop-down list, duplicate entries appear. The scenario invol ...

Switching XML to JSON using React.js

Currently, I am in the process of developing an application with a requirement to retrieve data from a web API that provides XML responses. However, my objective is to obtain this information in JSON format, but unfortunately, the API does not offer suppor ...

Error: The index "id" is not defined

Hey there, I have been working on fetching data from a JSON URL located at this link. However, I seem to be encountering an error that I can't quite comprehend. If anyone has any insights or solutions, I would greatly appreciate the help. Thank you in ...

What is the best way to customize the default zoom level and position of a map in Google Data Studio?

Is there a way to customize the default zoom level and position of a map chart in Google Data Studio using JSON code? This is the JSON code that can be used for customization: [ { "featureType": "road.local", "stylers&quo ...

MongoDB querying based on conditions

I am a beginner when it comes to MongoDB and node.js, and I could really use some guidance on performing a mongo lookup. My goal is to join two documents based on a specific condition within my Conversation model using mongoose, node, and express. Let&apo ...

Navigating JSON with Java/Jackson

I am currently working on a Java application to parse JSON data from the Reddit API. The sample JSON data I am trying to parse is structured like this: [ { "kind": "Listing", "data": { "modhash": "1jq62oyvwe15aaba7eb18b0b4363b567a007507663 ...

The json_decode function in PHP along with AJAX is returning an error stating "Invalid

Shown below is a sample json string data [{"ratetype":"Y","hotelPackage":"N","roomtype":"Deluxe Double Room","roombasis":",Complimentary Wi-Fi Internet, Breakfast, ","roomTypeCode":"0000015468","ratePlanCode":"0000120709","ratebands":{"validdays":"1111111 ...

Unresolved promise: Internal server issue

I encountered an exception while working on my Nativescript app. EXCEPTION: Uncaught (in promise): Server error JS: ORIGINAL STACKTRACE: JS: Error: Uncaught (in promise): Server error JS: at resolvePromise (/data/data/com.yourdomain.appname/files/app/ ...