javascript - %j specifier in console.log excludes some properties -


I recently used to load the bson (binary JSON) module in the node Was trying. Js . API documents were not clear, so I thought inspecting the object would help me, the results of the inspection started to flare up.

Finally I came to know that it was because I was using % j which is "false" - this is an object's chips! (I am using Python terminology for "attributes" as things referred to with dot, and "dictionary keys" for things referenced with brackets, because I do not know the proper name for these things in JS.)

Here is an example:

  requires var bson = ("BSN"); Console.log ("%% as Seasoning: Jay J:% J", BSN); Console.log ("BSN as console.log:", BSON);   

And here is the output:

  bson% j: as {"BSonPure": {}, "BSONNative": {}} of the console BSN log in form: {code: [function: code], symbol: [function: symbol], BSON: {[function: BSON] BSONIGT 32_MX: 2147483647, BSONItTMRM: -2147483648, BSONIdt64_mx: 9223372036854776000, BSONIIT 64_MIN: -9223372036854776000, ..   

I thought that since x.key is the same form as x ["key"] , it means that The properties and the dictionary key are "the same thing" in JS I think that is BSON.BSONPure {} , but BSON.BSONPure.BSON And BSON.BSONPure ["BSON"] is a function object!

It leads me to believe that whatever "% j" does, some keys somehow. How does it determine which key to exclude? why will? JS is really confusing language!

Related Tags:

node.js , % j placeholder result in a call JSON.stringify () passed on the logic.

This is it, in passing your BSON variable, you are not passing valid JSON objects, you can pass a node. JS module Which are exporting functions among other things.

So, what happens when the JSON.stringify () hits the function?

If a deadline, a function, or a symbol is encountered during conversion, then it is omitted or left (when it is found in the object) or empty Sensor is done (when it is found in an array). ()

Therefore the behavior you are seeing is completely expected, you are trying to log something as JSON that is not valid Is JSON .

  & gt; JSON.stringify ({name: "Bob"}) & gt; "{" Name ":" bob "}" & gt; JSON.stringify ({func: function () {}}) & gt; "{}"    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -