Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!