-1

I have the following json

{  "EmployeeLists": [
{
  "ID": 1,
  "NAME": "Anand",
  "Salary": 90000
},
{
  "ID": 2,
  "NAME": "Anbu",
  "Salary": 80000 
},
{
  "ID": 3,
  "NAME": "Bala",
  "Salary": 85000
}  ]}

I want to move the array item 2 to up or down. the expected output is like below.

{  "EmployeeLists": [
{
  "ID": 2,
  "NAME": "Anbu",
  "Salary": 80000
},
{
  "ID": 1,
  "NAME": "Anand",
  "Salary": 90000
},
{
  "ID": 3,
  "NAME": "Bala",
  "Salary": 85000
} ]}
1

1 Answer 1

4

You can swap the 2 elements like so:

var x = EmployeeLists[2];
EmployeeLists[2] = EmployeeLists[1];
EmployeeLists[1] = x;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.