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

Add an implementation for JSValueEncoder #116

Open
MaxDesiatov opened this issue Jan 6, 2021 · 4 comments
Open

Add an implementation for JSValueEncoder #116

MaxDesiatov opened this issue Jan 6, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented Jan 6, 2021

Do I understand correctly that there's no easy way right now to convert an arbitrary Encodable type to JSValue? We already have JSValueDecoder, but apparently lack the opposite for Encodable...

@MaxDesiatov MaxDesiatov added the enhancement New feature or request label Jan 6, 2021
@jhoughjr
Copy link

What all would this entail? I assume an inverse of the decoding method?

@MaxDesiatov
Copy link
Contributor Author

Yes, I would assume so, but it may need some investigation to confirm this.

@jhoughjr
Copy link

Ive discovered a bug it seems that might relate to this issue.

working with Request and Fetch apis.
long story short no matter what body I send to my server, JavaScriptKit seems to ensure it is the string literal [object Object] even if I give it my own string literal.
Thats not a log output either, its the decode utf8 data on the request at the server.

I tested this by setting body to a JSValue(stringLiteral: ) of the exact json body I wanted.
What does my served decode the 15 bytes as [object Object]
This is the exact same output as body = body.description
info is available for the last few days in the tokamak channel.

So if it cant send the body I tell it to, Encoding won't matter cuz it will just encode the literal string "[object Object]"

@ephemer
Copy link

ephemer commented Oct 17, 2022

@kateinoigakukun @j-f1 FYI I have created an implemention of JSValueEncoder. I can make a PR soon – just testing it some more first with some more use-cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants