Nested json response from 3 one to many tables
In PostgreSQL:

SELECT
    row_to_json (r1.*)
FROM
    (
        SELECT 
            table_1_id, 
            somedata,
            array(
                SELECT
                    row_to_json (r2.*)
                FROM
                (
                SELECT 
                        table_2_id, 
                        somedata,
                        array(
                            SELECT
                                row_to_json(r3.*, true)
                            FROM
                            (
                                SELECT
                                    table_3.table_3_id,
                                    table_3.somedata
                                FROM
                                    table_3
                                WHERE
                                    table_3.table_2_id = table_2.table_2_id
                                ORDER BY
                                    table_3_id
                            ) r3

                        ) AS table_2_data
                  FROM 
                        table_2  
                 WHERE 
                        table_2.table_1_id = table_1.table_1_id 
                 ORDER BY 
                        table_2_id
                ) r2
           ) AS table_2_data
        FROM 
            table_1
    ) AS r1


(with a few caveats, because your first level response is not an array; and I think it should).

The syntax is a bit convoluted and can probably be simplified

Test it at http://rextester.com/SEZ32413