Skip to content

Add AddJsonBody overload to serialise top-level string - #2043

Merged
alexeyzimarev merged 2 commits into
devfrom
json-string-body
Apr 4, 2023
Merged

Add AddJsonBody overload to serialise top-level string#2043
alexeyzimarev merged 2 commits into
devfrom
json-string-body

Conversation

@alexeyzimarev

@alexeyzimarevalexeyzimarev commented Apr 3, 2023

Copy link
Copy Markdown
Member

Description

Proposal to fix#1954.

Add a AddJsonBody overload with string payload argument with forceSerialize argument. If forceSerialize is set to true, the string will be serialised. If it's set to false, the string will be sent as-is.

Purpose

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

It's not a strictly breaking change, I think it might be released a s a minor version.

@cloudflare-workers-and-pages

cloudflare-workers-and-pagesBot commented Apr 4, 2023

Copy link
Copy Markdown

Deploying with Cloudflare Pages Cloudflare Pages

Latest commit:b27dff0
Status: ✅ Deploy successful!
Preview URL:https://8f5407b7.restsharp.pages.dev
Branch Preview URL:https://json-string-body.restsharp.pages.dev

View logs

@alexeyzimarevalexeyzimarev changed the title Hacky way to find out if the JSON body string is already serializedAdd AddJsonBody overload to serialise top-level stringApr 4, 2023
@alexeyzimarev
alexeyzimarev merged commit bf24794 into devApr 4, 2023
@repo-ranger
repo-rangerBot deleted the json-string-body branch April 4, 2023 16:33
@d-a-s

Copy link
Copy Markdown

I'd recommend you consider adding this as a breaking change in the release notes.

I recently upgraded an old project that was relying on the previous top level string behavior (encoding by default).

Sign up for freeto 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.

AddJsonBody handles strings in a usually user-friendly but incorrect way

2 participants

@alexeyzimarev@d-a-s