bson

What is the use of type javascript/javascriptwithscope of bson

浪尽此生 提交于 2020-01-14 19:48:06
问题 I am wondering about the use of these two type of bson (javascript/javascriptwithscope); as the base type of bson. What's the use case of it and how to generate a javascriptwithscope object to save in mongodb? Type Number Alias Notes Double 1 “double” String 2 “string” Object 3 “object” Array 4 “array” Binary data 5 “binData” Undefined 6 “undefined” Deprecated. ObjectId 7 “objectId” Boolean 8 “bool” Date 9 “date” Null 10 “null” Regular Expression 11 “regex” DBPointer 12 “dbPointer” JavaScript

OutOfMemory Exception with Streams and BsonWriter in Json.Net

寵の児 提交于 2020-01-06 07:25:45
问题 I'm having a problem using Json.net and creating a large Bson file. I have the following test code: Imports System.IO Imports Newtonsoft.Json Public Class Region Public Property Id As Integer Public Property Name As String Public Property FDS_Id As String End Class Public Class Regions Inherits List(Of Region) Public Sub New(capacity As Integer) MyBase.New(capacity) End Sub End Class Module Module1 Sub Main() Dim writeElapsed2 = CreateFileBson_Stream(GetRegionList(5000000)) GC.Collect(0) End

unresolved dependency org.mongodb#bson#2.5, bad organisation in sbt

牧云@^-^@ 提交于 2020-01-03 17:23:30
问题 I'm trying to use "org.apache.mahout" % "mahout-integration" % "0.7" as a dependency inside my play2 based web application. [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: org.mongodb#bson;2.5: java.text.ParseException: inconsistent module descriptor file found in 'http://repo1.maven.org/maven2/org/mongodb/bson/2.5/bson-2.5.pom': bad organisation: expected='org.mongodb' found='org.bson';

Serializing Immutable Value types with Mongo C# Driver

て烟熏妆下的殇ゞ 提交于 2020-01-01 18:17:15
问题 I have many immutable value type classes, for example EmailAddress , which ensure any non null instance is valid. I would like to control the serialization of these types of objects to be just the standard string representation ( "123@abc.com" ) when persisted using MongoDB C# Driver. I have tried implementing the IBsonSerilizer however it will only allow for objects or arrays at the root level. I was able to implement proper Json Serilization with Json.NET, is there a different approach I

Storing composite/nested object graph

早过忘川 提交于 2020-01-01 12:16:34
问题 I am currently developing a document store in Mongo DB which contains a complete material breakdown of a specific item. The breakdown is calculated and contains a composite structure. The domain model: public interface IReagent { int ItemId { get; set; } int Quantity { get; set; } ConcurrentBag<IReagent> Reagents { get; set; } } public class Craft : IReagent { public int ItemId { get; set; } public int Quantity { get; set; } public int SpellId { get; set; } public int Skill { get; set; }

MongoDB: BSON to JSON

时光毁灭记忆、已成空白 提交于 2020-01-01 09:55:40
问题 I'm using the native mongoDB driver for node.js. I'd like to get some data from the database and send it as a JSON string via HTTP. Is there a way to convert the BSON to JSON or directly retrieve the data as JSON from the database? Thanks! 回答1: In python you can use the simplejson encoder to convert bson to json as follows: result = db.mycol.find({ ....}) json = simplejson.dumps(result) It will convert all simple objects, but will have difficulties with others, for example datetime will not

Why is JSON faster than BSON in node.js?

微笑、不失礼 提交于 2020-01-01 08:36:43
问题 After reading this, there is a quote that stood out: BSON is also designed to be fast to encode and decode. For example, integers are stored as 32 (or 64) bit integers, so they don't need to be parsed to and from text. This uses more space than JSON for small integers, but is much faster to parse . From what I am reading, the entire point of using BSON is because it is less taxing on the CPU and faster to encode/process. But, I did some tests with Node.js and using a native JSON approach

Bson array (de)serialization with Json.NET

萝らか妹 提交于 2019-12-30 17:39:11
问题 I am simply trying to serialize and deserialize a string array in Bson format using Json.NET, but the following code fails: var jsonSerializer = new JsonSerializer(); var array = new string [] { "A", "B" }; // Serialization byte[] bytes; using (var ms = new MemoryStream()) using (var bson = new BsonWriter(ms)) { jsonSerializer.Serialize(bson, array, typeof(string[])); bytes = ms.ToArray(); } // Deserialization using (var ms = new MemoryStream(bytes)) using (var bson = new BsonReader(ms)) { //

Bson pretty print using Java MongoDb driver

我怕爱的太早我们不能终老 提交于 2019-12-30 07:22:09
问题 I am using the Mongo Aggregation Framework using the Java MongoDB driver, version 3.3. I have an aggregagtion pipeline , that is merely collection of type List<Bson> . I am trying to find a way to pretty print each stage of the pipeline. Calling the toString method on each element is not sufficient, because each stages is an instance of a simple implementation of the Bson interface, which is SimplePipelineStage . This stupid class has not any override of the toString method. The pipeline is

Protocol Buffers versus JSON or BSON [closed]

空扰寡人 提交于 2019-12-29 10:06:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 months ago . Does anyone have any information on the performance characteristics of Protocol Buffers versus BSON (binary JSON) or versus JSON in general? Wire size Serialization speed Deserialization speed These seem like good binary protocols for use over HTTP. I'm just wondering which would be better in the long run for a