0

I have the following table with some JSON data

| id  | from                                                     | to                                                  |
|-----|:--------------------------------------------------------:|----------------------------------------------------:|
| 001 | {"subject":"Foo","id":"D4014"}                           | {"subject":"Bar","id":"D4014"}                      |
|-----|----------------------------------------------------------|-----------------------------------------------------|
| 002 | {"id":"D4014","state":{"id":"GP2","name":"In progress"}} | {"id":"D4014","state":{"id":"GP8","name":"Closed"}} |
|     |                                                          |                                                     |
|     |                                                          |                                                     |

It represents the changes of a record. For simple attribute (in this example subject) and for relationships (state). A JSON can hold multiple attributes too.

From

{"id":"D4014","state":{"id":"GP2","name":"In progress"}, "description": "BarBaz"}

To

{"id":"D4014","state":{"id":"GP3","name":"Hold"}, "description": "Qux"}

I want to transform this JSON objects (text) to a view table.

|  id | record_id | property |     from    | to     | from_id | to_id |
|:---:|-----------|----------|:-----------:|--------|---------|-------|
| 001 | D4014     | subject  | Foo         | Bar    |         |       |
| 002 | D4014     | state    | In progress | Closed | GP2     | GP8   |
|     |           |          |             |        |         |       |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.