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

Added support for unquoted String Values #1

Merged
merged 1 commit into from
Dec 28, 2018
Merged

Conversation

asopenag
Copy link
Owner

I've found lately JSONs with unquoted String values (it seems to be called relaxed json), so I've updated the code to support those:

In this version, if you set the setting JsonOptions.AllowUnquotedKeys to True it will also allow unquoted Strings. Unquoted Strings (in this version) end once we find a space, a coma, a "}" or a "]".

Notice that this will capture the true/false/null/numbers as strings (not having the quotes to identify the strings, all are a potential Strings), so we check them afterwards and:

  • If IsNumeric() we convert the value back to number using VBA.Val().
  • If = "null" -> Null
  • If = "true" / "false" -> True / False

Next steps: We should clarify the setting JsonOptions.AllowUnquotedKeys : (a) rename it to clarify it works for both key and values or (b) create a new setting to allow unquote key/values separately.

I've found lately JSONs with unquoted String values (it seems to be called [relaxed json](http://www.relaxedjson.org/)), so I've updated the code to support those:

In this version, if you set the setting `JsonOptions.AllowUnquotedKeys` to `True` it will also allow unquoted Strings. Unquoted Strings (in this version) end once we find a space, a coma, a "}" or a "]".

Notice that this will capture the true/false/null/numbers as strings (not having the quotes to identify the strings, all are a potential Strings), so we check them afterwards and:
- If `IsNumeric()` we convert the value back to number using `VBA.Val()`.
- If  = "null" -> `Null`
- If = "true" / "false" -> `True` / `False`

**Next steps:** We should clarify the setting `JsonOptions.AllowUnquotedKeys` : (a) rename it to clarify it works for both key and values or (b) create a new setting to allow unquote key/values separately.
@asopenag asopenag merged commit 3c68359 into master Dec 28, 2018
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.

1 participant