-2

I have a json

{
  "timer": {
    "19272": {
      "asset_id": 9354,
      "original_total_time": 5,
      "original_warning_time": null
    }
  },
  "SEBKeys": [],
  "scoreMappings": []
}

I need to extract 'original_total_time' value from this json using Postgres.

Can anyone help?

4
  • If you're using PHP, you can use json_decode(). Commented May 12, 2021 at 3:41
  • Is there any way that i can get in query itself? Commented May 12, 2021 at 3:52
  • whether your JSON structure is fix or dynamic Commented May 12, 2021 at 4:07
  • 1
    I got the solution (SELECT * , requests.request -> 'notes' -> json_object_keys((requests.request ->> 'notes')::json) ->> 'message' AS message FROM requests) Commented May 12, 2021 at 4:10

1 Answer 1

0

If your JSON structure is fixed then you can use following query

select json_->'timer'->'19272'->>'original_total_time' from test

DEMO

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.