Json::encode deepness limitation?

I’m fetching the product table with it’s relations:




$products = Product::find()

            ->with(['test',

                'test.a',

                'test.b',

                'producta',

                'productb'])

            ->all();


echo Json::encode($products);



Unfortunately it only echoes the contents of the product table, without the tables listed in “with”. Any idea what’s wrong here?

It seems to work when adding ->asArray() to find(). Is that working as intended? :P

Oh wow, this one is ugly, when using ->asArray() Json::encode doesn’t know the field types. You need to use json encode with JSON_NUMERIC_CHECK to avoid that.