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

Utility method to serialize objects to query params #119

Merged
merged 4 commits into from Aug 12, 2020

Conversation

lyyder
Copy link
Contributor

@lyyder lyyder commented Aug 6, 2020

Adds a utility function: sharetribeSdk.util.objectQueryString that takes an object and turns it into a Flex API string object representation: attr1:val1;attr2:val2;arr1:entry1,entry2. This format is used in Flex APIs for example in public data search filters and custom image variants.

  • does not support nested objects
  • skips null values
  • arrays are serialized to comma-separated lists, other values are stringified as they are

The function is exposed as a static function in the SDK index file in util path.

docs/image-variants.md Outdated Show resolved Hide resolved
docs/image-variants.md Outdated Show resolved Hide resolved
docs/image-variants.md Outdated Show resolved Hide resolved
src/sdk.js Outdated Show resolved Hide resolved
src/util.js Outdated Show resolved Hide resolved
src/util.js Outdated Show resolved Hide resolved
src/util.test.js Outdated Show resolved Hide resolved
@lyyder lyyder changed the title Custom image variants utility function Utility method to serialize objects to query params Aug 10, 2020
@lyyder lyyder force-pushed the image-variant-util-fn branch 2 times, most recently from b575bda to 8a6cda5 Compare August 10, 2020 06:30
src/util.js Outdated Show resolved Hide resolved
src/util.js Outdated Show resolved Hide resolved
src/util.js Outdated Show resolved Hide resolved
src/util.js Outdated Show resolved Hide resolved
@lyyder lyyder force-pushed the image-variant-util-fn branch 2 times, most recently from b3c3628 to 0d36914 Compare August 11, 2020 12:43
@lyyder lyyder force-pushed the image-variant-util-fn branch 3 times, most recently from 7b2a1cd to e79ba60 Compare August 11, 2020 13:21
Add a page regarding image varinats and the variant desc util fn.
@lyyder lyyder merged commit 5963644 into master Aug 12, 2020
@lyyder lyyder deleted the image-variant-util-fn branch August 12, 2020 07:26
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.

None yet

4 participants