0
I’m having difficulty listing the values of a Json, but it results from it is an array within an array as you can see below;
{
"status": true,
"valores": {
"USD": {
"nome": "D\u00f3lar",
"valor": 3.2789,
"ultima_consulta": 1521232205,
"fonte": "UOL Economia - http:\/\/economia.uol.com.br\/"
},
"EUR": {
"nome": "Euro",
"valor": 4.0303,
"ultima_consulta": 1521428406,
"fonte": "UOL Economia - http:\/\/economia.uol.com.br\/"
},
"ARS": {
"nome": "Peso Argentino",
"valor": 0.1627,
"ultima_consulta": 1521428407,
"fonte": "UOL Economia - http:\/\/economia.uol.com.br\/"
},
"GBP": {
"nome": "Libra Esterlina",
"valor": 4.572,
"ultima_consulta": 1521428407,
"fonte": "UOL Economia - http:\/\/economia.uol.com.br\/"
},
"BTC": {
"nome": "Bitcoin",
"valor": 26500,
"ultima_consulta": 1521455704,
"fonte": "Mercado Bitcoin - http:\/\/www.mercadobitcoin.com.br\/"
}
}
}
It’s based on this link from Json
Json values => click here
I’m following this tutorial
To list the values I performed this test, but I had no results;
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8"/>
<title>teste</title>
<link rel="stylesheet" type="text/css" href="node_modules/bootstrap/dist/css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="node_modules/font-awesome/css/font-awesome.css"/>
</head>
<body>
<div class="container" id="app">
<div class="row">
</div>
<div class="row">
<ol>
<li v-for="bancodedado in bancodedados">
{{ bancodedado.valores }}
<ul>
<li v-for="usd in valores.USD" >
{{ usd.valor }}
</li>
</ul>
</li>
</ol>
</div>
</div>
<script src="node_modules/vue/dist/vue.js"></script>
<script src="node_modules/vue-resource/dist/vue-resource.js"></script>
<script >
var app = new Vue({
el: '#app',
data: {
bancodedados: []
},
methods: {
},
created: function() {
var self = this;
self.$http.get('http://api.promasters.net.br/cotacao/v1/valores').then(function(response) {
self.bancodedados = response.body.results;
});
},
});
======================================================
I made that attempt and I didn’t succeed, and I didn’t succeed.
<ol>
<li v-for="( bandodedado, key) in bancodedados ">
<ul>
<li>
<li>
{{ key }} : {{ bandodedado }}
</li>
</li>
</ul>
</li>
</ol>
Could someone show me how to list array values?
The
JSON
does not represent aarray
within aarray
. It is an object that has some properties that are also objects.– Pagotti
thank you very much, but you would have like to help me in my problem?
– wladyband
What I suggest you do is take the object when you come back from ajax and turn it into an array with the structure you need and then put this array into your Vue "date" object.
– Pagotti
you would have to show an example or a template you have on the internet for me to have an idea of how to do it? please.
– wladyband