gpt4 book ai didi

javascript - 将 JSON 值合并到变量或字符串中

转载 作者:行者123 更新时间:2023-11-28 09:12:50 25 4
gpt4 key购买 nike

我的 JSON 节点具有相同的标题,但每个节点中的纬度和经度值不同。我需要检查相同的标题值,然后将纬度和经度值合并到 map API 的 url 中。我需要它按纬度、经度、纬度、经度等顺序排列...我只是不知道此时该怎么办。感谢您的帮助或建议。

JS VAR

<img class="detail_map" src="http://open.mapquestapi.com/staticmap/v4/getplacemap?size=320,240&zoom=15&location=' + data.nodes.Latitude + ',' + data.nodes.Longitude + '&imagetype=jpeg&showicon=blue-1">

JSON 对象

var data = fl({
"nodes":[
{"node":{
"title":"180","Address":"555 Market St. San Francisco, CA United States See map: Google Maps","
Latitude":"37.789952","
Longitude":"-122.400158"}},
{"node":{
"title":"180","Address":"Epic Roasthouse (399 Embarcadero) San Francisco, CA United States See map: Google Maps","
Latitude":"37.797677","
Longitude":"-122.394339"}},
{"node":{
"title":"180","Address":"Mason &amp; California Streets (Nob Hill) San Francisco, CA United States See map: Google Maps","
Latitude":"37.791556","
Longitude":"-122.410766"}},
{"node":{
"title":"180","Address":"Justin Herman Plaza San Francisco, CA United States See map: Google Maps","
Latitude":"37.774930","
Longitude":"-122.419416"}},
{"node":{
"title":"180","Address":"200 block Market Street San Francisco, CA United States See map: Google Maps","
Latitude":"37.793133","
Longitude":"-122.396560"}}
]});

});

最佳答案

您可以使用$.extend()合并两个对象的函数,不同的属性将被替换。

示例:

var newData = $.extend(data1, data2);
// Assuming data1, data2 are objects;

如果需要将字符串 JSON 转换为对象,请使用 $.parseJSON()

关于javascript - 将 JSON 值合并到变量或字符串中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16093159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com