• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

272
Vistas
Angular 2, split data from Json

Hi I have a json from http request, the server json response is this:

{
  "map": {
    "03/04": 13,
    "05/04": 41,
    "06/04": 1,
    "12/04": 4,
    "14/04": 7,
    "18/04": 8,
    "19/04": 2,
    "22/04": 1,
    "25/04": 4
  },
  "links": []
}

I want to split dates in 1 array and values in other array, At the end I want : Data[03/04,05/04,06/04....] and Val[13,41,1....] is it possible without difficult implementation?

over 3 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

This could be an approach:

   private Data = [];
   private Val = [];
   for (let key in data) {
      this.Data.push(key);
      this.Val.push(data[key])
   }
over 3 years ago · Santiago Trujillo Denunciar

0

you can use this

  var a=`{
          "map": {
            "03/04": 13,
            "05/04": 41,
            "06/04": 1,
            "12/04": 4,
            "14/04": 7,
            "18/04": 8,
            "19/04": 2,
            "22/04": 1,
            "25/04": 4
          },
          "links": []
        }`

        var Data=[];
        var val=[]
        for(each in a.map){
            Data.push(each);
            val.push(a.map[each]);
        }
over 3 years ago · Santiago Trujillo Denunciar

0

let date = Object.keys(JsonRespond.map) // get all keys in map object
let value = [];
date.forEach((key) => {
   value.push(JsonRespond.map[key]);
})
over 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda