You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Or, after #89 was merged, we can just pass the serializer instance to render :json, because all Rails does is calling .as_jon, which was aliased to .serializable_hash on #89.
But my question is: isn't the performance gains of this gem actually due to the generation of the stringified JSON? Because it seems that using this pattern we're just using fast_jsonapi to generate a Ruby Hash, and then leaving to Rails .to_json to actually stringify it (which I assume uses ActiveSupport::json.encode, based on this article)
Or am I missing something here?
The text was updated successfully, but these errors were encountered:
feliperaul
changed the title
Question: generating JSON for react components
Question: generating JSON for react components: whats the point in using the gem if Rails .to_json is used for dumping
Jun 10, 2018
JSON dumping is very fast <5ms for most normal payloads if you use OJ, Yajl etc. Generating the ruby hash is generally what takes a lot of time in AMS. We have optimized that by focusing on jsonapi.org schema and optimizing for homogeneous arrays.
Based on #89, it seems that the pattern to generate JSON for consuming in a react component is this:
render json: WidgetSerializer.new(widget).serialized_hash
Or, after #89 was merged, we can just pass the serializer instance to render :json, because all Rails does is calling
.as_jon
, which was aliased to.serializable_hash
on #89.But my question is: isn't the performance gains of this gem actually due to the generation of the stringified JSON? Because it seems that using this pattern we're just using fast_jsonapi to generate a Ruby Hash, and then leaving to Rails
.to_json
to actually stringify it (which I assume uses ActiveSupport::json.encode, based on this article)Or am I missing something here?
The text was updated successfully, but these errors were encountered: