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

Parse escaped chars #2

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

schorschii
Copy link

Hi! First of all, thanks for this library!

I noticed that it does not parse escaped chars like \n or \u00fc (ü), see here.

This change adds support for those escaped values.

@mikezs
Copy link
Owner

mikezs commented Nov 6, 2023

I've added some suggestions, and please add some tests for each of the scenarios and edge cases please

@schorschii
Copy link
Author

schorschii commented Nov 6, 2023

I added a test for \n and \u00fc and also fixed the testEscapedQuoteString() test:


let input = """
["\\\""]
"""

results in ["\""], which is just a " when decoding the JSON string. The previous version expected \" which is wrong.

I've added some suggestions

What do you mean? I can't see any comments or changes on the code.

@mikezs
Copy link
Owner

mikezs commented Nov 7, 2023

What do you mean? I can't see any comments or changes on the code.

They're comments on the code made on this pull request, see here: #2

@schorschii
Copy link
Author

I'm sorry but I can't see any comments.

Copy link
Owner

@mikezs mikezs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, apparently I left this in draft

Source/JSON.swift Outdated Show resolved Hide resolved
@@ -596,7 +596,29 @@ open class JSON {
}
}

let parsedString = String(jsonString[startingIndex ..< index])
var parsedString = String(jsonString[startingIndex ..< index])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could stay as a constant and be given a different name and built upon, e.g.
let initialParsedString = String()
let parsedString = initialParsedString.someOperation()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is useful. I mean how would you implement this for the hexEncodedUnicodeCharRegex parsedString? Feel free to push your solution on this branch.

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