<tfoot id='Nd2bM'></tfoot>

      <i id='Nd2bM'><tr id='Nd2bM'><dt id='Nd2bM'><q id='Nd2bM'><span id='Nd2bM'><b id='Nd2bM'><form id='Nd2bM'><ins id='Nd2bM'></ins><ul id='Nd2bM'></ul><sub id='Nd2bM'></sub></form><legend id='Nd2bM'></legend><bdo id='Nd2bM'><pre id='Nd2bM'><center id='Nd2bM'></center></pre></bdo></b><th id='Nd2bM'></th></span></q></dt></tr></i><div id='Nd2bM'><tfoot id='Nd2bM'></tfoot><dl id='Nd2bM'><fieldset id='Nd2bM'></fieldset></dl></div>
        <bdo id='Nd2bM'></bdo><ul id='Nd2bM'></ul>

        <legend id='Nd2bM'><style id='Nd2bM'><dir id='Nd2bM'><q id='Nd2bM'></q></dir></style></legend>

        <small id='Nd2bM'></small><noframes id='Nd2bM'>

      1. “JSON.stringify"中的“符号键控"是什么意思

        What does #39;symbol-keyed#39; mean in `JSON.stringify`(“JSON.stringify中的“符号键控是什么意思)
      2. <legend id='Z0Fw5'><style id='Z0Fw5'><dir id='Z0Fw5'><q id='Z0Fw5'></q></dir></style></legend>
      3. <small id='Z0Fw5'></small><noframes id='Z0Fw5'>

          <tbody id='Z0Fw5'></tbody>

          <i id='Z0Fw5'><tr id='Z0Fw5'><dt id='Z0Fw5'><q id='Z0Fw5'><span id='Z0Fw5'><b id='Z0Fw5'><form id='Z0Fw5'><ins id='Z0Fw5'></ins><ul id='Z0Fw5'></ul><sub id='Z0Fw5'></sub></form><legend id='Z0Fw5'></legend><bdo id='Z0Fw5'><pre id='Z0Fw5'><center id='Z0Fw5'></center></pre></bdo></b><th id='Z0Fw5'></th></span></q></dt></tr></i><div id='Z0Fw5'><tfoot id='Z0Fw5'></tfoot><dl id='Z0Fw5'><fieldset id='Z0Fw5'></fieldset></dl></div>
            <tfoot id='Z0Fw5'></tfoot>
                  <bdo id='Z0Fw5'></bdo><ul id='Z0Fw5'></ul>
                  本文介绍了“JSON.stringify"中的“符号键控"是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有一个Node.js生成的Object,当我使用console.log时是这样的:

                  There is a Object generated by Node.js, it looks like this when I use console.log:

                  { dataValues: { a: 1, b: 2 }, fn1: function(){}, fn2: function(){} }
                  

                  当我使用 JSON.stringify 时,它会返回这个字符串:

                  when I use JSON.stringify, it return this string:

                  {"a":1,"b":1}
                  

                  我检查了 mozilla 开发者中心,发现 这个:

                  I checked the mozilla developer center and found this:

                  所有 symbol-keyed 属性将被完全忽略,即使在使用替换功能时也是如此.

                  All symbol-keyed properties will be completely ignored, even when using the replacer function.

                  我认为 'dataValues' 必须是 'symbol-keyed' 属性,但 'symbol-keyed' 是什么意思?

                  I think the 'dataValues' must be the 'symbol-keyed' property, but what does 'symbol-keyed' mean?

                  顺便说一句,我使用 sequelizejs ORM 库来生成这个对象.

                  btw, I use the sequelizejs ORM lib to generate this object.

                  推荐答案

                  我终于在同一个地方找到了原因页面:

                  I found the reason finally in the same page:

                  如果被字符串化的对象有一个名为 toJSON 且值为函数的属性,则 toJSON 方法自定义 JSON 字符串化行为:而不是被序列化的对象,调用时由 toJSON 方法返回的值将被序列化.

                  If an object being stringified has a property named toJSON whose value is a function, then the toJSON method customizes JSON stringification behavior: instead of the object being serialized, the value returned by the toJSON method when called will be serialized.

                  它在浏览器上正常运行.这是 jsfiddle 按照我的要求运行它.

                  It runs on browser normally. Here is the jsfiddle to run it like I asked.

                  代码:

                  function test(data) {
                      for(var key in data){
                          this[key] = data[key];
                      }
                  }
                  
                  test.prototype.toJSON = function(){
                      return this.dataValues;
                  }
                  
                  var a = new test({dataValues: {a:1, b:2}});
                  
                  console.log(a);//the instance
                  console.log(JSON.stringify(a));//{"a":1,"b":1}
                  

                  这篇关于“JSON.stringify"中的“符号键控"是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                  How to get number of video views with YouTube API?(如何使用 YouTube API 获取视频观看次数?)

                  • <small id='Iu5ll'></small><noframes id='Iu5ll'>

                      <bdo id='Iu5ll'></bdo><ul id='Iu5ll'></ul>
                      <i id='Iu5ll'><tr id='Iu5ll'><dt id='Iu5ll'><q id='Iu5ll'><span id='Iu5ll'><b id='Iu5ll'><form id='Iu5ll'><ins id='Iu5ll'></ins><ul id='Iu5ll'></ul><sub id='Iu5ll'></sub></form><legend id='Iu5ll'></legend><bdo id='Iu5ll'><pre id='Iu5ll'><center id='Iu5ll'></center></pre></bdo></b><th id='Iu5ll'></th></span></q></dt></tr></i><div id='Iu5ll'><tfoot id='Iu5ll'></tfoot><dl id='Iu5ll'><fieldset id='Iu5ll'></fieldset></dl></div>

                      <tfoot id='Iu5ll'></tfoot>
                        1. <legend id='Iu5ll'><style id='Iu5ll'><dir id='Iu5ll'><q id='Iu5ll'></q></dir></style></legend>
                              <tbody id='Iu5ll'></tbody>