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

JSON.Merge fails if the first character in a value is a quote mark #19

Open
davegraham92120 opened this issue Aug 4, 2018 · 1 comment

Comments

@davegraham92120
Copy link
Contributor

If the first character of a value is a quote (i.e., Char ( 34 )), JSON.Merge treats the value as JSONRaw, which alters the value.

For instance, given take this valid JSON value: ""Full Name" [email protected]"

JSON.Merge lets FileMaker decide it's type, which results in data loss:

Let ( foo = Quote ( "First Last" ) & "<[email protected]>" ;  
	JSONSetElement ( "{}" ; "bar" ; foo ; "" )
) = {"bar":"First Last"}

We need to make sure to cast it as a JSONString:

Let ( foo = Quote ( "First Last" ) & "<[email protected]>" ;  
	JSONSetElement ( "{}" ; "bar" ; foo ; JSONString )
) = {"bar":"\"First Last\"<[email protected]>"}

We need to include a check for at least Char (34) when deciding to explicitly cast the JSONSetElement as a JSONString, and possibly other values as well.

Stay tuned for the file that includes the test and fix.

@davegraham92120 davegraham92120 self-assigned this Aug 4, 2018
@davegraham92120
Copy link
Contributor Author

The revised code checks for the first character being a quote:

JSONType = If( ( needToCheckForNumber and GetAsText(thisValue) <> GetAsNumber(thisValue)) or firstChar = "\"" ; JSONString ; "") ;

There's a new test. All tests are passing.

JSONAdditions-Fixed GH 19.fmp12.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants