json / jsonb default type map for results

Issue #212 wontfix
ippa lix
created an issue


I've started switching from document-databases to using Postgresql jsonb.

I noticed there's no automatic typemap for jsonb-columns. I do set the type_map_for_results:

@pg = PG.connect( ... )
@pg.type_map_for_results = PG::BasicTypeMapForResults.new @pg

Which works fine for array-columns and others but not json. While looking through the code it seems like it's there but commented out.

Wouldn't something like the following make sense as default?

JSON.parse( json/jsonb data from pg)  # => Hash

Thanks for a great lib! Feels like postgres is having alot of momentum now.

Comments (3)

  1. Lars Kanis

    Thank you for your suggestion. In fact BasicTypeMapForResults is very new and incomplete. JSON support should be added, but it's not high priority for me currently. Feel free to post a pull request (alternatively on github, if you like).

  2. Log in to comment