Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ShopifyVM] Minify input json #361

Closed
wants to merge 2 commits into from
Closed

[ShopifyVM] Minify input json #361

wants to merge 2 commits into from

Conversation

mssalemi
Copy link
Contributor

@mssalemi mssalemi commented Sep 12, 2024

Addresses: https://github.com/Shopify/shopify-functions/issues/394

This PR introduces a new function, minify_json, aimed at standardizing the handling of JSON data across our system's backend and Function Runner components. The primary goal is to ensure that JSON data is consistently processed in its minified form, promoting efficiency and reducing discrepancies in data handling practices between different environments.

Background:

Currently, there is an inconsistency in how JSON data is managed between our backend and the function-runner. The backend measures the size of JSON strings using .bytesize on minified strings. Function runner has been handling JSON data without explicit minifying the input, potentially leading to larger data sizes - could lead to issues with difference of partner machines

Changes:

add a minify_json Function: This function takes a byte slice as input and performs the following operations:

  • Deserialize: Converts the byte slice into a serde_json::Value to validate the JSON structure.
  • Serialization: serde_json::Value -> back into a byte vector (minifying the JSON)
  • Deserialization: Converts the minified byte vector back into a serde_json::Value
  • Integration in Function Runner: The minify_json function get called when we are reading the input.

^ might be a better way to do this 🤔

Next Steps:

  • 👀

@jacobsteves
Copy link
Member

Closing as this was implemented in another PR.

@jacobsteves jacobsteves closed this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants