Answer the question
In order to leave comments, you need to log in
Comparing two JSON arrays and replacing duplicates in modern JavaScript (ES6)?
Good time of the year.
There are two huge JSON arrays with commodity items, which arrives from the backend. The first is a list of goods, prices and modifications common to all users. The second is personal for each user, where there may be a price for any product modification.
The first (main) looks like:
[
{
"id": 1,
"name": "Межкомнатная дверь",
"price_list": [
[ 0, 1, 2, 3, 8300 ],
// где:
// 0 — ID типоразмера, 1 — ID цвета, 2 — ID коллекции,
// 3 — ID стиля, 8300 — цена в руб.
// + ещё несколько модификаций этой же двери
// с ценой в таком же формате
]
},
{
// ... следующие 100500 дверей с модификациями и ценами
}
]
[
{
"id": 1,
"name": "Межкомнатная дверь",
"user_id": 1, // ID пользователя, у которого своя колонка цен на сайте
"price_list": [
[ 0, 1, 2, 3, 4300 ] // своя цена только на эту модель двери и всё
]
}
]
Unfortunately, this cannot be done on the backend, so you have to dance from what is - from the front.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question