N
N
NeTLeaDeR2018-02-25 15:55:20
PHP
NeTLeaDeR, 2018-02-25 15:55:20

How to change json structure?

Hello. I have a json array

{"status":1,"response":{"AK-47 | Aquamarine Revenge (Battle-Scarred)":{"price":1045,"quantity":63},"AK-47 | Aquamarine Revenge (Factory New)":{"price":2928,"quantity":70},"AK-47 | Aquamarine Revenge (Field-Tested)":{"price":1300,"quantity":264},"AK-47 | Aquamarine Revenge (Minimal Wear)":{"price":1997,"quantity":141},"AK-47 | Aquamarine Revenge (Well-Worn)":{"price":1163,"quantity":125},"AK-47 | Black Laminate (Battle-Scarred)":{"price":995,"quantity":18},"AK-47 | Black Laminate (Factory New)":{"price":7929,"quantity":12},"AK-47 | Black Laminate (Field-Tested)":{"price":886,"quantity":99},"AK-47 | Black Laminate (Minimal Wear)":{"price":1045,"quantity":154}
Etc.
It is necessary to make such
{"AK-47 | Aquamarine Revenge (Battle-Scarred)":{"last_updated":1467615630,"quantity":149,"value":632},"AK-47 | Aquamarine Revenge (Factory New)":{"last_updated":1467615630,"quantity":65,"value":2796}

i.e. add the last_update field, with time and change price to value. How to implement this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Sanych, 2018-02-25
@NeTLeaDeR

  1. decode json
  2. loop through the array and add a last_update field to each element
  3. encode json

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question