Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
How can I add an array name in the json data

I am getting the data like this

[
  { "id":1,
    "name":"john"
  },
  { "id":2,
    "name":"ram"
  }
] 

I want to change the above data to below

 "array":
[
  { "id":1,
    "name":"john"
  },
  { "id":2,
    "name":"ram"
  }
]
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The way to format your object in JavaScript would be something like this:

{ 
  "array": [
    { "id":1, "name":"john" },
    { "id":2, "name":"ram" }
  ]
{
about 4 years ago · Juan Pablo Isaza Denunciar

0

I did not get this statement I want to do this question using angular only how can we achieve the output like that in angular as it's all about structuring/wrapping the JSON data. Hence, I added the solution in angular.js snippet below.

Demo (Angular) :

function ArrayController($scope) {
    const resData = [{
    "id":1,
    "name":"john"
    }, {
    "id":2,
    "name":"ram"
  }]; 
    $scope.data = {
    array: resData
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.1/angular.min.js"></script>
<div ng-app ng-controller="ArrayController">
    <div>{{ data }}</div>
</div>

about 4 years ago · Juan Pablo Isaza 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda