[Vuejs]-Vuejs changes order of json_encoded array, when decodes it back from props in vuejs component

0👍

In Javascript keys of objects have no order. If you need a specific order then use arrays.

0👍

Here is documentation for keyBy Laravel method: https://laravel.com/docs/5.6/collections#method-keyby

I wanted to have ids for rows data to fast and easy access without iterating over all rows and check if there is somewhere key Id which is equals with my particular Id.

Solution: not to use keyBy method in Laravel and pass json string to Vue component like following [{some data}, {some data}] (as I described in my Question Edit section) – this will remain array order as it used to be.

I found this short and elegant way how to do this, instead of writing js function by myself:

Its find() method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find

Example:

let row = records.find( record => record.id === idToFind );

Leave a comment