{"action":"created","issue":{"url":"https://api.github.com/repos/atuttle/Taffy/issues/321","repository_url":"https://api.github.com/repos/atuttle/Taffy","labels_url":"https://api.github.com/repos/atuttle/Taffy/issues/321/labels{/name}","comments_url":"https://api.github.com/repos/atuttle/Taffy/issues/321/comments","events_url":"https://api.github.com/repos/atuttle/Taffy/issues/321/events","html_url":"https://github.com/atuttle/Taffy/issues/321","id":155955574,"number":321,"title":"RFC: Allow developers to use a special character in combination with a new serializer to prevent CF from serializing strings containing only numeric data as numeric values","user":{"login":"atuttle","id":46990,"avatar_url":"https://avatars.githubusercontent.com/u/46990?v=3","gravatar_id":"","url":"https://api.github.com/users/atuttle","html_url":"https://github.com/atuttle","followers_url":"https://api.github.com/users/atuttle/followers","following_url":"https://api.github.com/users/atuttle/following{/other_user}","gists_url":"https://api.github.com/users/atuttle/gists{/gist_id}","starred_url":"https://api.github.com/users/atuttle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atuttle/subscriptions","organizations_url":"https://api.github.com/users/atuttle/orgs","repos_url":"https://api.github.com/users/atuttle/repos","events_url":"https://api.github.com/users/atuttle/events{/privacy}","received_events_url":"https://api.github.com/users/atuttle/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/atuttle/Taffy/labels/Code:%20Not%20Started","name":"Code: Not Started","color":"e11d21"},{"url":"https://api.github.com/repos/atuttle/Taffy/labels/Difficulty:%201%20point","name":"Difficulty: 1 point","color":"e102d8"},{"url":"https://api.github.com/repos/atuttle/Taffy/labels/Docs:%20Incomplete","name":"Docs: Incomplete","color":"fef2c0"},{"url":"https://api.github.com/repos/atuttle/Taffy/labels/Status:%20Under%20Review","name":"Status: Under Review","color":"000000"},{"url":"https://api.github.com/repos/atuttle/Taffy/labels/Type:%20Enhancement","name":"Type: Enhancement","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/atuttle/Taffy/milestones/10","html_url":"https://github.com/atuttle/Taffy/milestones/Taffy%204.0","labels_url":"https://api.github.com/repos/atuttle/Taffy/milestones/10/labels","id":1638995,"number":10,"title":"Taffy 4.0","description":"The version where we finally abandon CF8, maybe?\r\n\r\nFull rewrite to be 100% script? Maybe even skip CF9/10 support and jump straight to member functions/etc?","creator":{"login":"atuttle","id":46990,"avatar_url":"https://avatars.githubusercontent.com/u/46990?v=3","gravatar_id":"","url":"https://api.github.com/users/atuttle","html_url":"https://github.com/atuttle","followers_url":"https://api.github.com/users/atuttle/followers","following_url":"https://api.github.com/users/atuttle/following{/other_user}","gists_url":"https://api.github.com/users/atuttle/gists{/gist_id}","starred_url":"https://api.github.com/users/atuttle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atuttle/subscriptions","organizations_url":"https://api.github.com/users/atuttle/orgs","repos_url":"https://api.github.com/users/atuttle/repos","events_url":"https://api.github.com/users/atuttle/events{/privacy}","received_events_url":"https://api.github.com/users/atuttle/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":4,"state":"open","created_at":"2016-03-11T14:19:09Z","updated_at":"2016-05-25T00:17:22Z","due_on":null,"closed_at":null},"comments":8,"created_at":"2016-05-20T12:48:23Z","updated_at":"2016-10-02T14:55:53Z","closed_at":null,"body":"**Problem:** Some text fields will sometimes contain only numeric data, and when CF's implementation of SerializeJson sees this, it attempts to be helpful and convert that to a numeric. E.g. when a phone number doesn't have any hyphens or other punctuation:\r\n\r\n```js\r\n[{\r\n  \"phone\": \"555-867-5309\"\r\n},\r\n{\r\n  \"phone\": 5558675309\r\n}]\r\n```\r\n\r\n**Proposed Solution:** (Based on an idea from @evagoras) Establish a convention for a non-printable special character that Taffy will automatically strip from all data after json serialization. Probably via a new opt-in serializer, something like this:\r\n\r\n```js\r\ncomponent extends=\"taffy.core.nativeJsonSerializer\" {\r\n  function getAsJson() taffy:mime=\"application/json;text/json\" taffy:default=\"true\" {\r\n    var serialized = super.getAsJson();\r\n    var clean = serialized.replace( chr(2), \"\", \"ALL\" );\r\n    return clean;\r\n  }\r\n}\r\n```\r\n\r\n`chr(2)` is the special non-printable character \"start-text\" (STX), and has been shown to force CF to treat a variable as a string when passed through SerializeJson, E.g:\r\n\r\n```js\r\n{\r\n  \"phone\": \"{STX}5558675309\"\r\n}\r\n```\r\n\r\nWith this opt-in serializer in use, you could inject a `chr(2)` into any variable to force it to render as a string, e.g.:\r\n\r\n```js\r\nreturn rep(queryToArray(myQuery, function(row){\r\n  row.phone = chr(2) & row.phone;\r\n  return row;\r\n}));\r\n```\r\n\r\nAfter the serializer has done its job, the final output will be (a string of numerics, not a numeric value):\r\n\r\n```js\r\n{\r\n  \"phone\": \"5558675309\"\r\n}\r\n```\r\n\r\n---\r\nThis approach does add a little bit more overhead in both rendering your query to an array, and then stripping the special characters from your serialized json, but it is a guaranteed outcome, and one that some people may prefer over a field that is sometimes numeric, sometimes a string, depending on its contents."},"comment":{"url":"https://api.github.com/repos/atuttle/Taffy/issues/comments/250975352","html_url":"https://github.com/atuttle/Taffy/issues/321#issuecomment-250975352","issue_url":"https://api.github.com/repos/atuttle/Taffy/issues/321","id":250975352,"user":{"login":"ryanguill","id":1149698,"avatar_url":"https://avatars.githubusercontent.com/u/1149698?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanguill","html_url":"https://github.com/ryanguill","followers_url":"https://api.github.com/users/ryanguill/followers","following_url":"https://api.github.com/users/ryanguill/following{/other_user}","gists_url":"https://api.github.com/users/ryanguill/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanguill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanguill/subscriptions","organizations_url":"https://api.github.com/users/ryanguill/orgs","repos_url":"https://api.github.com/users/ryanguill/repos","events_url":"https://api.github.com/users/ryanguill/events{/privacy}","received_events_url":"https://api.github.com/users/ryanguill/received_events","type":"User","site_admin":false},"created_at":"2016-10-02T14:55:53Z","updated_at":"2016-10-02T14:55:53Z","body":"Are the labels up to date on this issue - it looks like you've got at least a start on it - is there more to do?"}}
{"actor":{"display_login":"ryanguill"}}