Skip to content
Studio 3T - The professional GUI, IDE and client for MongoDB
  • Tools
    • Aggregation Editor
    • IntelliShell
    • Visual Query Builder
    • Export Wizard
    • Import Wizard
    • Query Code
    • SQL Query
    • Connect
    • Schema Explorer
    • Compare
    • SQL ⇔ MongoDB Migration
    • Data Masking
    • Task Scheduler
    • Reschema
    • More Tools and Features
  • Solutions
  • Resources
    • Knowledge Base
    • MongoDB Tutorials & Courses
    • Tool/Feature Documentation
    • Reports
    • Case Studies
    • Whitepapers
    • Blog
    • Testimonials
    • Community
  • Contact us
    • Contact
    • Sales Support
    • Feedback and Support
    • Career
    • About Us
  • Store
    • Buy Now
    • Preferred Resellers
    • Team Pricing
  • My License
  • Download
search

How do I copy and paste plain JSON from Studio 3T? #Studio3T_AMA

Posted on: 29/09/2021 (last updated: 04/10/2021) by DJ Walker-Morgan

Q: I want to cut and paste plain JSON from Studio 3T into other applications but when I view a document I see numeric fields appear such as NumberInt(4). What can I do about it?

Welcome to the latest Studio 3T Ask Manatees Anything – #Studio3T_AMA. Want to know how to use Studio 3T to make your MongoDB life better? Just tweet and use #Studio3T_AMA or email [email protected].

A: What you are seeing in the JSON view is, by default, the Mongo shell’s version of the data in your database, as JSON. It is also called Extended JSON and there’s a couple of versions of it. Extended JSON is all about preserving type information in something that’s quite like, but not quite JSON.

If you want to see your data in plain, un-extended JSON, then the JSON:Pure view option, new in Studio 3T 2021.4, will be very useful.

When you are viewing a collection in the JSON view, clicking the cog next to the view type will display the view menu. Your view will likely be set to JSON: Mongo Shell Format. In that menu, you’ll also find JSON: Pure, without MongoDB types.

The cog menu for a JSON view reveals four different JSON formats available.
The cog menu for a JSON view reveals four different JSON formats available.

Now the view will be a plain, typeless JSON, ideal for cutting and pasting.

If you select View Document, either from the right click menu, icon or pressing F3, you’ll also find a similar menu in that view. 

The View Document JSON view options
The View Document JSON view options

Set it to JSON: Pure and copy and paste JSON data anywhere.

Why Not Pure JSON?

There is an important warning that goes with JSON: Pure; you are losing information when you switch to it, specifically what type the data is. JSON only supports strings and numbers while MongoDB’s BSON format allows data to be stored as, for example, integers, double, 128-bit decimals, strings, binary, dates and objectids.

That means when you display a field where the field type is integer, while JSON: Pure would show it as

{ "Field": 5 }

If you updated a document with that format of data, MongoDB would interpret the field as a double (the default) and discard the integer type data.

JSON: Mongo Shell Format would show it as:

{ "Field": NumberInt(5) }

When you update using that format, the integer nature of the field is retained.

And that’s why when you call up the Edit Document operation in the Collections View, you’ll find there’s no option to change the format. It’s locked down to JSON: Mongo shell to ensure that no type data is lost. That is especially important for id fields which, by default, are ObjectId types are wrapped withObjectId(). Similarly, dates, which are Date types are wrapped with ISODate(). This is done so they can be efficiently parsed and processed. 

Those other JSON views

Finally, for the curious, those JSON views explained:

  • JSON: Mongo Shell Format – the default format; anything that is not a natural JSON type (string or number) is wrapped in an object constructor such as ObjectID, NumberInt, Decimal128 or ISODate. These wrappers tend not to be parsable by generic JSON tools. Best for most MongoDB related things.
  • JSON: Simple Format – this format attempts to make all fields a string or number, except for fields which are ObjectID or Date types. Those, and only those, are wrapped in a constructor. They still tend not to be parsable by generic JSON tools. Useful in some cases, but JSON: Pure might be the better option.
  • JSON: MongoExport Format – This format retains the type information but entirely in JSON. That’s done by turning typed data into a JSON object. So  ObjectId("613f1b49d6b66c04ee84f370") becomes { "$oid" : "613f1b49d6b66c04ee84f370" }. This is also called strict Extended JSON. Any application reading it will need to know how to interpret the type objects. Generic JSON tools will be able to read the files. Best for interchange between MongoDB databases.

And as we’ve discussed…

  • JSON: Pure – This format discards the type data and renders the file in a pure JSON format. So, ObjectId("613f1b49d6b66c04ee84f370") becomes the string "613f1b49d6b66c04ee84f370". Generic JSON tools can happily parse and work with this data but watch out for loss of precision when handling numbers and no indications of what fields are dates. Best for interoperability with JSON tools and JSON-consuming systems.

Plain JSON is Pure JSON

So the lesson in this AMA is Plain JSON is also Pure JSON in Studio 3T. Pure JSON views take out all the type information from MongoDB’s Extended JSON. It does leave you with JSON ready to cut and paste. As long as you are aware that the type information is gone and the precision of some values may be compromised, you should be good to go.


How helpful was this article?
This article was hideous
This article was bad
This article was ok
This article was good
This article was great
Thank you for your feedback!

About The Author

DJ Walker-Morgan

Dj has been around since Commodore had Pets and Apples grew everywhere. With a background in Unix and development, he's been around the technology business writing code or writing content ever since.

Related articles

  • How do I export (or copy and paste) particular columns of data? #Studio3T_AMA
  • How to Copy and Paste MongoDB Documents
  • How to Copy a MongoDB Collection to Another Database
  • How to Copy MongoDB Databases Across Servers
  • Copy MongoDB Query Results to CSV, Excel & Google Sheets

Tags

academy aggregation AMA atlas community connections date tags events export features hackolade import intellishell JSON knowledge base migration modelling mongodb mongoodb productivity query regex releases schema security SQL Studio 3T tasks tips updates webinar windows

Browse by MongoDB topic

  • Connecting to MongoDB
  • Database Administration & Security
  • Getting Started with MongoDB
  • Getting Started with Studio 3T
  • Import/Export
  • Job Automation & Scheduling
  • MongoDB Aggregation Framework
  • MongoDB/Studio 3T Workshops
  • Performance
  • Query & CRUD Operations
  • Reference
  • Schema
  • Studio 3T Licensing
  • Support and other resources
  • Working with MongoDB & SQL
  • Working with MongoDB Atlas

Studio 3T

MongoDB Enterprise Certified Technology PartnerSince 2014, 3T has been helping thousands of MongoDB developers and administrators with their everyday jobs by providing the finest MongoDB tools on the market. We guarantee the best compatibility with current and legacy releases of MongoDB, continue to deliver new features with every new software release, and provide high quality support.

Find us on FacebookFind us on TwitterFind us on YouTubeFind us on LinkedIn

Education

  • Free MongoDB Tutorials
  • Connect to MongoDB
  • Connect to MongoDB Atlas
  • Import Data to MongoDB
  • Export MongoDB Data
  • Build Aggregation Queries
  • Query MongoDB with SQL
  • Migrate from SQL to MongoDB

Resources

  • Feedback and Support
  • Sales Support
  • Knowledge Base
  • FAQ
  • Reports
  • Case Studies
  • White Papers
  • Testimonials
  • Discounts

Company

  • About Us
  • Blog
  • Careers
  • Legal
  • Press
  • Privacy Policy
  • EULA

© 2022 3T Software Labs GmbH. All rights reserved.

  • Privacy Policy
  • Cookie settings
  • Impressum
When you click "Accept", you are agreeing to cookies being on your device. They may improve site navigation, site usage analysis, or the relevance of messages. It is up to you which cookies are enabled. Read our Privacy Policy.
Manage cookies
Accept
✕

Privacy Preference Center

A cookie is a small file of letters and numbers that is downloaded on to your computer when you visit a website. Cookies are used by many websites and can do a number of things, eg remembering your preferences, recording what you have put in your shopping basket, and counting the number of people looking at a website. In the form below you can choose which cookies, except for essential cookies, to allow or disable.

Accept all cookies

Manage consent preferences

Essential cookies are strictly necessary to provide an online service such as our website or a service on our website which you have requested. The website or service will not work without them.

Performance cookies allow us to collect information such as number of visits and sources of traffic. This information is used in aggregate form to help us understand how our websites are being used, allowing us to improve both our website’s performance and your experience.

Functional cookies collect information about your preferences and choices and make using the website a lot easier and more relevant. Without these cookies, some of the site functionality may not work as intended.

Social media cookies are cookies used to share user behaviour information with a third-party social media platform. They may consequently effect how social media sites present you with information in the future.

Accept selected