Closed MrTob closed 2 years ago
Hello, I would like to store the response from an API in the database. The response looks like this.
callback ( { "webext2": true, "version": "1.0", "title": "Example Response", "pubDate": "Fri, 26 Aug 2022 08:17:04 +0200", "list_lenght": 3, "list": { "0": { "entry": { "id": "1001", "text": "Hello World", "nestedObj": { "id": "10", "text": "Hello World" }, "feuerwehrenarray": { "0": { "id": "100", "text": "Hello World" }, "1": { "id": "101", "text": "Hello World" } } } }, "0": { "entry": { "id": "1002", "text": "Hello World", "nestedObj": { "id": "10", "text": "Hello World" }, "feuerwehrenarray": { "0": { "id": "100", "text": "Hello World" } } } } } } )
now i want to send a get request with pgsql-http that returns only the entries from the list cause i want to store them in a table
select content::json->'list' from http_get('http://example.com/api');
Why does the command not work? is it the callback()? How can I access the object inside?
Your return data is not JSON, it's JSONP (aka "JSON wrapped in a function call") so you'll probably need to regexp away the function wrapper before passing the remainder into the JSON parser.
Hello, I would like to store the response from an API in the database. The response looks like this.
now i want to send a get request with pgsql-http that returns only the entries from the list cause i want to store them in a table
Why does the command not work? is it the callback()? How can I access the object inside?