什么是$$ hashKey添加到我的JSON.stringify结果 [英] What is the $$hashKey added to my JSON.stringify result
问题描述
我试图寻找在Mozilla他们的文档的JSON字符串化页面以及这里SO和谷歌,但没有发现任何解释。我已经使用JSON字符串化很多时间,但从来没有碰到过这样的结果。
I have tried looking on the Mozilla JSON stringify page of their docs as well as here on SO and Google but found no explanation. I have used JSOn stringify many time but never come across this result
我有JSON对象的数组
I have an array of JSON objects
[
{
"param_2": "Description 1",
"param_0": "Name 1",
"param_1": "VERSION 1"
},
{
"param_2": "Description 2",
"param_0": "Name 2",
"param_1": "VERSION 2"
},
{
"param_2": "Description 3",
"param_0": "Name 3",
"param_1": "VERSION 3"
}
]
贴在我的 $范围
为了和 POST
他们为我所用的JSON.stringify 1 paramater( )方法,我也得到了以下内容:
attached to my $scope
and in order to POST
them as one paramater I used the JSON.stringify() method and I get the following:
[
{
"param_2": "Description 1",
"param_0": "Name 1",
"param_1": "VERSION 1",
"$$hashKey": "005"
},
{
"param_2": "Description 2",
"param_0": "Name 2",
"param_1": "VERSION 2",
"$$hashKey": "006"
},
{
"param_2": "Description 3",
"param_0": "Name 3",
"param_1": "VERSION 3",
"$$hashKey": "007"
}
]
我只是好奇,究竟是如我所料更类似于从字符串化方法如下东西$$ hashkey:
I am just curious what exactly is the $$hashkey as I expected something more similar to the following from the stringify method:
[
{
"1":{
"param_2": "Description 1",
"param_0": "Name 1",
"param_1": "VERSION 1"
},
"2":{
"param_2": "Description 2",
"param_0": "Name 2",
"param_1": "VERSION 2"
},
"3":{
"param_2": "Description 3",
"param_0": "Name 3",
"param_1": "VERSION 3"
}
}
]
我不知道这是否是一个因素,但我使用在服务器端Angularjs 1.1.5,1.8.2的JQuery和Spring 3.0.4和Spring 3.0.7安全
这不是我causeing任何问题,但我想知道的原因和理由 $$ hashkey
It is not causeing me any issues but I would like to know the cause and reason for the $$hashkey
推荐答案
角添加此跟踪的变更,所以它知道何时需要更新DOM。
Angular adds this to keep track of your changes, so it knows when it needs to update the DOM.
如果您使用 angular.toJson(OBJ)
而不是 JSON.stringify(OBJ)
则角将剥离为你这些内部使用的值。
If you use angular.toJson(obj)
instead of JSON.stringify(obj)
then Angular will strip out these internal-use values for you.
另外,如果你改变你重复前pression使用由{uniqueProperty} 后缀轨道,角就不必添加
$$ hashKey
可言。例如:
Also, if you change your repeat expression to use the track by {uniqueProperty}
suffix, Angular won't have to add $$hashKey
at all. For example
<ul>
<li ng-repeat="link in navLinks track by link.href">
<a ng-href="link.href">{{link.title}}</a>
</li>
</ul>
只要永远记得你所需要的链接。恩pression的一部分 - 我总是倾向于忘记这一点。刚按部就班地进行,HREF
肯定不行的。
这篇关于什么是$$ hashKey添加到我的JSON.stringify结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!