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

[BUG] toJson() incorrectly decodes encoded characters #5282

Open
RainerAtSpirit opened this issue Apr 26, 2024 · 1 comment
Open

[BUG] toJson() incorrectly decodes encoded characters #5282

RainerAtSpirit opened this issue Apr 26, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@RainerAtSpirit
Copy link
Contributor

RainerAtSpirit commented Apr 26, 2024

Description

This originated from this discord support question: https://discord.com/channels/814605913783795763/1232719654355599492

Steps to Reproduce

Using Elsa 3.1.2 import the encoding-issue.json and run it.

encoding-issue.json

In SetVariable an object is store in the Params variable.

return {
    german: "öäüÜÖÄß",
    secret: "Käse~!@#$%^&()_+-=/|:;'<>?,.", 
    spanish: "ñáéí"
}

In getParams() this is compared with the original string, which returns true

return getParams()?.secret === "Käse~!@#$%^&()_+-=/|:;'<>?,."

In JSON.stringify() this is compared with the original string, which returns true

JSON.parse(JSON.stringify(getParams()))?.secret === "Käse~!@#$%^&()_+-=/|:;'<>?,."

In toJson() this is compared with the original string, which returns false

JSON.parse(toJson(getParams()))?.secret === "Käse~!@#$%^&()_+-=/|:;'<>?,."

image

The writeline text Käse~!@#$%^&()_�-=/|:;'//?,. is not equal to Käse~!@#$%^&()_+-=/|:;'<>?,.

Expected result: toJson() decodes encoded characters correctly.

@RainerAtSpirit RainerAtSpirit added the bug Something isn't working label Apr 26, 2024
Copy link

glime-ai bot commented Apr 26, 2024

To address the issue you're experiencing with the toJson() function not decoding encoded characters correctly, it's important to understand that toJson() is a function provided by Elsa to serialize .NET objects to JSON. The behavior you're observing, where toJson() does not return the expected result, could be due to a bug or limitation in the way Elsa handles the serialization of special characters.

Given that JSON.stringify() is working as expected, but toJson() is not, it suggests that there might be a discrepancy in how these two functions handle character encoding. Since JSON.stringify() is a standard JavaScript function and toJson() is specific to Elsa, it's possible that toJson() is not handling the encoding in the same way.

To resolve this issue, you may want to report this behavior to the Elsa team as a potential bug. You can create an issue on the Elsa GitHub repository, providing the details of your findings and the steps to reproduce the problem. The Elsa team or the community can then investigate the issue further and potentially provide a fix or a workaround.

In the meantime, if JSON.stringify() is producing the correct results, you might consider using it as a temporary solution until toJson() is fixed, provided that it meets your requirements and you are only dealing with JSON objects.

If you need further assistance or guidance, please provide additional context or clarify your specific needs, and I'll be happy to help.

This comment was generated by Glime.

@sfmskywalker sfmskywalker self-assigned this Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Triage
Development

No branches or pull requests

2 participants