digitalmars.D.learn - Manipulate and parse jasonb object in timescaledb(postgresql)
- Alain De Vos (4/4) Jul 14 2021 When I read a record out of the database I receive a jsonb
- Alain De Vos (5/5) Jul 14 2021 With good select operators i can extract the data i need for
- jfondren (7/12) Jul 14 2021 You'll need to either lean on postgres's support for jsonb
- Alain De Vos (3/3) Jul 14 2021 As an example i show this.
- jfondren (3/6) Jul 14 2021 That's JSON, not JSONB. D has JSON support in
- Steven Schveighoffer (8/12) Jul 15 2021 Isn't jsonb just a storage assumption for the database (so it can do
When I read a record out of the database I receive a jsonb datatatype as a string. How do I convert this string into a json object and parse and manipulate it?
Jul 14 2021
With good select operators i can extract the data i need for instance: select measurement->'room.temperature' from mytable; Now how to process that further as json object ? or jsonb object in dlang ?
Jul 14 2021
On Wednesday, 14 July 2021 at 21:56:11 UTC, Alain De Vos wrote:With good select operators i can extract the data i need for instance: select measurement->'room.temperature' from mytable; Now how to process that further as json object ? or jsonb object in dlang ?You'll need to either lean on postgres's support for jsonb querying to avoid having to pull a jsonb string into D, or you'll have to write a jsonb library. I don't see one in dub, and it's a bit hard to search for C libraries for it that you might interface easily with (or even where the type is defined. Is it a postgres invention?)
Jul 14 2021
As an example i show this. https://docs.python.org/3/library/json.html But that is more what i look for.
Jul 14 2021
On Thursday, 15 July 2021 at 01:08:28 UTC, Alain De Vos wrote:As an example i show this. https://docs.python.org/3/library/json.html But that is more what i look for.That's JSON, not JSONB. D has JSON support in https://dlang.org/phobos/std_json.html
Jul 14 2021
On 7/14/21 9:00 AM, Alain De Vos wrote:When I read a record out of the database I receive a jsonb datatatype as a string. How do I convert this string into a json object and parse and manipulate it?Isn't jsonb just a storage assumption for the database (so it can do efficient indexing/searches)? When you get the data back, I would think it's just json data you can parse. I don't have experience with it, but I can't imagine a portable psql library that actually implements whatever binary storage format is being used inside the DB. -Steve
Jul 15 2021