{"action":"created","issue":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/2132","repository_url":"https://api.github.com/repos/Starcounter/Starcounter","labels_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/2132/labels{/name}","comments_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/2132/comments","events_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/2132/events","html_url":"https://github.com/Starcounter/Starcounter/issues/2132","id":36758126,"number":2132,"title":"Number casting in Typed JSON","user":{"login":"warpech","id":566463,"avatar_url":"https://avatars.githubusercontent.com/u/566463?v=3","gravatar_id":"","url":"https://api.github.com/users/warpech","html_url":"https://github.com/warpech","followers_url":"https://api.github.com/users/warpech/followers","following_url":"https://api.github.com/users/warpech/following{/other_user}","gists_url":"https://api.github.com/users/warpech/gists{/gist_id}","starred_url":"https://api.github.com/users/warpech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/warpech/subscriptions","organizations_url":"https://api.github.com/users/warpech/orgs","repos_url":"https://api.github.com/users/warpech/repos","events_url":"https://api.github.com/users/warpech/events{/privacy}","received_events_url":"https://api.github.com/users/warpech/received_events","type":"User","site_admin":false},"labels":[{"id":4413437,"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":47544721,"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/Puppets","name":"Puppets","color":"006b75","default":false},{"id":45294495,"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/Typed%20JSON","name":"Typed JSON","color":"006b75","default":false}],"state":"closed","locked":false,"assignee":{"login":"chrhol","id":1658979,"avatar_url":"https://avatars.githubusercontent.com/u/1658979?v=3","gravatar_id":"","url":"https://api.github.com/users/chrhol","html_url":"https://github.com/chrhol","followers_url":"https://api.github.com/users/chrhol/followers","following_url":"https://api.github.com/users/chrhol/following{/other_user}","gists_url":"https://api.github.com/users/chrhol/gists{/gist_id}","starred_url":"https://api.github.com/users/chrhol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrhol/subscriptions","organizations_url":"https://api.github.com/users/chrhol/orgs","repos_url":"https://api.github.com/users/chrhol/repos","events_url":"https://api.github.com/users/chrhol/events{/privacy}","received_events_url":"https://api.github.com/users/chrhol/received_events","type":"User","site_admin":false},"assignees":[{"login":"chrhol","id":1658979,"avatar_url":"https://avatars.githubusercontent.com/u/1658979?v=3","gravatar_id":"","url":"https://api.github.com/users/chrhol","html_url":"https://github.com/chrhol","followers_url":"https://api.github.com/users/chrhol/followers","following_url":"https://api.github.com/users/chrhol/following{/other_user}","gists_url":"https://api.github.com/users/chrhol/gists{/gist_id}","starred_url":"https://api.github.com/users/chrhol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrhol/subscriptions","organizations_url":"https://api.github.com/users/chrhol/orgs","repos_url":"https://api.github.com/users/chrhol/repos","events_url":"https://api.github.com/users/chrhol/events{/privacy}","received_events_url":"https://api.github.com/users/chrhol/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/Starcounter/Starcounter/milestones/51","html_url":"https://github.com/Starcounter/Starcounter/milestone/51","labels_url":"https://api.github.com/repos/Starcounter/Starcounter/milestones/51/labels","id":602455,"number":51,"title":"v2.x","description":"","creator":{"login":"Starcounter-Jack","id":1219049,"avatar_url":"https://avatars.githubusercontent.com/u/1219049?v=3","gravatar_id":"","url":"https://api.github.com/users/Starcounter-Jack","html_url":"https://github.com/Starcounter-Jack","followers_url":"https://api.github.com/users/Starcounter-Jack/followers","following_url":"https://api.github.com/users/Starcounter-Jack/following{/other_user}","gists_url":"https://api.github.com/users/Starcounter-Jack/gists{/gist_id}","starred_url":"https://api.github.com/users/Starcounter-Jack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Starcounter-Jack/subscriptions","organizations_url":"https://api.github.com/users/Starcounter-Jack/orgs","repos_url":"https://api.github.com/users/Starcounter-Jack/repos","events_url":"https://api.github.com/users/Starcounter-Jack/events{/privacy}","received_events_url":"https://api.github.com/users/Starcounter-Jack/received_events","type":"User","site_admin":false},"open_issues":278,"closed_issues":596,"state":"open","created_at":"2014-03-19T09:04:00Z","updated_at":"2016-12-08T12:44:32Z","due_on":null,"closed_at":null},"comments":12,"created_at":"2014-06-29T21:50:24Z","updated_at":"2016-12-08T12:44:32Z","closed_at":"2016-12-08T12:44:32Z","body":"I stumbled upon this error in InvoiceDemo.\n\nConsider the following patch:\n\n``` json\n[{\"op\":\"replace\",\"path\":\"/Invoice/Items/0/Price$\",\"value\":\"11\"}]\n```\n- If `Price` property is of type **decimal** (declared in JSON as `\"price\": 0.0`), the above patch value will be _correctly_ converted to decimal `11`.\n- If `Price` property is of type **long** (declared in JSON as `\"price\": 0`), the above patch value will trigger exception:\n\n```\n500 InternalServerError\n\nSystem.FormatException: ScErrJsonValueWrongType (SCERR14004): The value does not correspond to the template property type. Property=\"Quantity (Int64)\", Value=\"3\"\nVersion: 2.0.2147.3.\nHelp page: https://github.com/Starcounter/Starcounter/wiki/SCERR14004.\n   at Starcounter.XSON.JsonPatch.JsonPatch.ParseAndProcess(TLong property, Json parent, IntPtr valuePtr, Int32 valueSize) in c:\\TeamCity\\TeamCity8\\buildAgent\\work\\build-nightly-2.0.2147.3\\Level1\\src\\Starcounter.XSON\\Sessions\\JSON-Patch\\JsonPatch.cs:line 759\n   at Starcounter.XSON.JsonPatch.JsonPatch.<>c__DisplayClass9.b__8() in c:\\TeamCity\\TeamCity8\\buildAgent\\work\\build-nightly-2.0.2147.3\\Level1\\src\\Starcounter.XSON\\Sessions\\JSON-Patch\\JsonPatch.cs:line 700\n   at Starcounter.Transaction.Add(Action action) in c:\\TeamCity\\TeamCity8\\buildAgent\\work\\build-nightly-2.0.2147.3\\Level1\\src\\Starcounter\\Transaction.cs:line 278\n   at Starcounter.XSON.JsonPatch.JsonPatch.HandleParsedPatch(Session session, JsonPointer pointer, IntPtr valuePtr, Int32 valueSize) in c:\\TeamCity\\TeamCity8\\buildAgent\\work\\build-nightly-2.0.2147.3\\Level1\\src\\Starcounter.XSON\\Sessions\\JSON-Patch\\JsonPatch.cs:line 692\n   at Starcounter.XSON.JsonPatch.JsonPatch.EvaluatePatches(Session session, IntPtr patchArrayPtr, Int32 patchArraySize) in c:\\TeamCity\\TeamCity8\\buildAgent\\work\\build-nightly-2.0.2147.3\\Level1\\src\\Starcounter.XSON\\Sessions\\JSON-Patch\\JsonPatch.cs:line 437\n   at Starcounter.Internal.PuppetRestHandler.b__2(Session session, Request request) in c:\\TeamCity\\TeamCity8\\buildAgent\\work\\build-nightly-2.0.2147.3\\Level1\\src\\Starcounter.Apps.JsonPatch\\BuiltInRestHandlers\\PuppetRestHandler.cs:line 43\n   at lambda_method(Closure , Request , IntPtr , IntPtr )\n   at Starcounter.Rest.UserHandlerInfo.RunUserDelegates(Request req, IntPtr methodAndUri, IntPtr rawParamsInfo, UriHandlersManager uhm) in c:\\TeamCity\\TeamCity8\\buildAgent\\work\\build-nightly-2.0.2147.3\\Level1\\src\\Starcounter.Rest\\UriHandlersManager.cs:line 197\n   at Starcounter.Rest.UriHandlersManager.RunDelegate(Request r, Response& resp) in c:\\TeamCity\\TeamCity8\\buildAgent\\work\\build-nightly-2.0.2147.3\\Level1\\src\\Starcounter.Rest\\UriHandlersManager.cs:line 524\n   at Starcounter.Internal.Web.AppRestServer.HandleRequest(Request request, Int32 handlerLevel) in c:\\TeamCity\\TeamCity8\\buildAgent\\work\\build-nightly-2.0.2147.3\\Level1\\src\\Starcounter.Apps.JsonPatch\\AppRestServer.cs:line 121\nHResult=-2146233033\nHelpLink=https://github.com/Starcounter/Starcounter/wiki/SCERR14004\n```\n\nI find such behaviour is at least inconsistent. Attractive solution from my perspective would be to convert strings to longs in similar manner as they are converted to doubles.\n\nYou might ask why Puppet client sends string patches to server when number was expected. The answer is that in HTML, value of every form element is a string. If server cannot handle the conversion, we will need to build converting logic in Puppet.js, which is also doable.\n"},"comment":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/comments/265731671","html_url":"https://github.com/Starcounter/Starcounter/issues/2132#issuecomment-265731671","issue_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/2132","id":265731671,"user":{"login":"chrhol","id":1658979,"avatar_url":"https://avatars.githubusercontent.com/u/1658979?v=3","gravatar_id":"","url":"https://api.github.com/users/chrhol","html_url":"https://github.com/chrhol","followers_url":"https://api.github.com/users/chrhol/followers","following_url":"https://api.github.com/users/chrhol/following{/other_user}","gists_url":"https://api.github.com/users/chrhol/gists{/gist_id}","starred_url":"https://api.github.com/users/chrhol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrhol/subscriptions","organizations_url":"https://api.github.com/users/chrhol/orgs","repos_url":"https://api.github.com/users/chrhol/repos","events_url":"https://api.github.com/users/chrhol/events{/privacy}","received_events_url":"https://api.github.com/users/chrhol/received_events","type":"User","site_admin":false},"created_at":"2016-12-08T12:44:32Z","updated_at":"2016-12-08T12:44:32Z","body":"😉 "}}
{"actor":{"display_login":"chrhol"}}