I see you already added it to Sequel as #to_json_data and it works 
_exactly_ how I was hoping it would.  Thank you!

On Thursday, February 4, 2021 at 8:37:44 AM UTC-8 Jeremy Evans wrote:

> On Wed, Feb 3, 2021 at 2:26 PM aguynamedryan <[email protected]> wrote:
>
>> Hi Jeremy,
>>
>> The desired output would be a Ruby Hash like 
>> {"id":1,"a2s":[{"id":1,"a1_id":1,"a3s":[{"id":1,"a2_id":1,"a4s":[{"id":1,"a3_id":1}]}]}]}
>>
>> Essentially, it's the JSON from the "A1#to_json" example, but with 
>> JSON.parse run on that output.
>>
>
> Understood.  Fixing this requires adding something like as_json and 
> removing the use of JsonSerializer::Literal.  Please try this patch: 
> https://gist.github.com/jeremyevans/642c4365521b3ec5c9a52177a3ce3b43 . 
> I'm not ready to commit the above patch yet as it needs tests added, but it 
> passes the existing tests and works with your example.
>
> Let's zoom out for a moment though.  What I'm _trying_ to do is get data 
>> out of PostgreSQL in the form of a JSON document that can be fed directly 
>> into MongoDB or some other document database.  Ruby Sequel is a _great_ way 
>> to get this done in a quick and easy fashion, but its turning out to be 
>> very slow.
>>
>> I'm now looking into using PostgreSQL's Array and JSON operators to group 
>> rows together into arrays and nest those arrays inside other rows.  I 
>> imagine Ruby Sequel can help me out here too, but I'm getting in over my 
>> head.
>>
>
> Using the PostgreSQL functions to generate json is going to be way faster 
> than doing it in Ruby, but probably more challenging to implement as well.
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/1e6f0046-85ba-4485-be51-1aaf1f38c155n%40googlegroups.com.

Reply via email to