带有 Object.values 的 GetJson,文本中带有逗号。如何摆脱这些逗号?
GetJson with Object.values with commas within text. How to get rid of these commas?
我想使用 GetJson 从 JSON 中获取特定值,但它会在 value/text 中插入逗号。这是我的 JSON:
的结构
{"api":
{"results":10,"fixtures":
[{"fixture_id":293298,
"league_id":1251,
"league":
{"name":"CONMEBOL Libertadores",
"country":"World",
"logo":.....
我正在尝试获取 "name" 值,即 "CONMEBOL Libertadores" 而不是 "C,O,N,M,E,B,O,L, ,L,i,b,e,r,t,a,d,o,r,e,s".
$(document).ready(function(){
$.getJSON("proxliberta.json", function(data) {
$.each(data.api.fixtures, function() {
});
console.log(Object.values(data.api.fixtures[1].league.name));
document.getElementById('val').innerHTML = Object.values(data.api.fixtures[1].league.name)
});
});
如何在我的回复中删除这些逗号?谢谢!
而不是
Object.values(data.api.fixtures[1].league.name)
尝试更改为,
data.api.fixtures[1].league.name
来源:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Object/values
我想使用 GetJson 从 JSON 中获取特定值,但它会在 value/text 中插入逗号。这是我的 JSON:
的结构{"api":
{"results":10,"fixtures":
[{"fixture_id":293298,
"league_id":1251,
"league":
{"name":"CONMEBOL Libertadores",
"country":"World",
"logo":.....
我正在尝试获取 "name" 值,即 "CONMEBOL Libertadores" 而不是 "C,O,N,M,E,B,O,L, ,L,i,b,e,r,t,a,d,o,r,e,s".
$(document).ready(function(){
$.getJSON("proxliberta.json", function(data) {
$.each(data.api.fixtures, function() {
});
console.log(Object.values(data.api.fixtures[1].league.name));
document.getElementById('val').innerHTML = Object.values(data.api.fixtures[1].league.name)
});
});
如何在我的回复中删除这些逗号?谢谢!
而不是
Object.values(data.api.fixtures[1].league.name)
尝试更改为,
data.api.fixtures[1].league.name
来源:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Object/values