Convert array of objects to array of arrays

Ray
var json = [{one: "text1", two: "text2", three: 3, four: 4},
            {one: "text3", two: "text4", three: 5, four: 6},
            {one: "text5", two: "text7", three: 8, four: 9}]

How can I convert the array of objects above into an array of arrays below?

var array = [["text1", "text2", 3, 4], 
             ["text3", "text4", 5, 6], 
             ["text5", "text7", 8, 9]]

Is there an ES2015 function to help convert it easily? If not a for loop might do.

mickl

You can use map and Object.values

let array = json.map(obj => Object.values(obj));

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I convert an array of arrays to an array of objects, selecting the key from other array?

分類Dev

Convert Array of objects to Array in angularjs

分類Dev

How to convert an array of arrays into a matrix?

分類Dev

Best way to Convert array of arrays into single array

分類Dev

Convert array of objects with nested array of objects into array-like object

分類Dev

Convert String to Array to Objects in Observable

分類Dev

Convert String to Array to Objects in Observable

分類Dev

How to convert array of items to array of objects?

分類Dev

How to get the combination of array values from nested arrays in an array of objects

分類Dev

Rethinkdb convert an array of objects to a single object

分類Dev

convert object keys and values to an array of objects

分類Dev

How to convert javascript array to specific list of objects

分類Dev

Convert an array of objects to a hash based on a property of the object

分類Dev

Unable to convert a nested object into an array of objects and viceversa

分類Dev

Convert JSON file to Typecript Array of Objects

分類Dev

merge array with array of arrays

分類Dev

Combine two arrays of objects into one array for use in Google Charts

分類Dev

How to get a the sum of multiple arrays within an array of objects?

分類Dev

Javascript ES6 calculate the sum of an array of arrays of objects

分類Dev

Merge two arrays of objects but have the second array pushed into an object key

分類Dev

Nested ng-repeat with array of objects which contain arrays

分類Dev

Mapping array to array of objects

分類Dev

Array into an array of objects in Java

分類Dev

Compare an array with an array of objects

分類Dev

convert different arrays to array of object using lodash or vanila js

分類Dev

How do I convert array of objects to object in javascript?

分類Dev

Convert Swift Array of Realm Objects Back to Realm Results

分類Dev

Turn object with (possible nested) arrays into an array of objects with single-item arrays

分類Dev

How to compare an array to an array of arrays?

Related 関連記事

  1. 1

    How can I convert an array of arrays to an array of objects, selecting the key from other array?

  2. 2

    Convert Array of objects to Array in angularjs

  3. 3

    How to convert an array of arrays into a matrix?

  4. 4

    Best way to Convert array of arrays into single array

  5. 5

    Convert array of objects with nested array of objects into array-like object

  6. 6

    Convert String to Array to Objects in Observable

  7. 7

    Convert String to Array to Objects in Observable

  8. 8

    How to convert array of items to array of objects?

  9. 9

    How to get the combination of array values from nested arrays in an array of objects

  10. 10

    Rethinkdb convert an array of objects to a single object

  11. 11

    convert object keys and values to an array of objects

  12. 12

    How to convert javascript array to specific list of objects

  13. 13

    Convert an array of objects to a hash based on a property of the object

  14. 14

    Unable to convert a nested object into an array of objects and viceversa

  15. 15

    Convert JSON file to Typecript Array of Objects

  16. 16

    merge array with array of arrays

  17. 17

    Combine two arrays of objects into one array for use in Google Charts

  18. 18

    How to get a the sum of multiple arrays within an array of objects?

  19. 19

    Javascript ES6 calculate the sum of an array of arrays of objects

  20. 20

    Merge two arrays of objects but have the second array pushed into an object key

  21. 21

    Nested ng-repeat with array of objects which contain arrays

  22. 22

    Mapping array to array of objects

  23. 23

    Array into an array of objects in Java

  24. 24

    Compare an array with an array of objects

  25. 25

    convert different arrays to array of object using lodash or vanila js

  26. 26

    How do I convert array of objects to object in javascript?

  27. 27

    Convert Swift Array of Realm Objects Back to Realm Results

  28. 28

    Turn object with (possible nested) arrays into an array of objects with single-item arrays

  29. 29

    How to compare an array to an array of arrays?

ホットタグ

アーカイブ