{"action":"closed","issue":{"url":"https://api.github.com/repos/ahausladen/JsonDataObjects/issues/14","labels_url":"https://api.github.com/repos/ahausladen/JsonDataObjects/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/ahausladen/JsonDataObjects/issues/14/comments","events_url":"https://api.github.com/repos/ahausladen/JsonDataObjects/issues/14/events","html_url":"https://github.com/ahausladen/JsonDataObjects/issues/14","id":96320417,"number":14,"title":"casting null values to any datatype raise exception","user":{"login":"kattunga","id":2139720,"avatar_url":"https://avatars.githubusercontent.com/u/2139720?v=3","gravatar_id":"","url":"https://api.github.com/users/kattunga","html_url":"https://github.com/kattunga","followers_url":"https://api.github.com/users/kattunga/followers","following_url":"https://api.github.com/users/kattunga/following{/other_user}","gists_url":"https://api.github.com/users/kattunga/gists{/gist_id}","starred_url":"https://api.github.com/users/kattunga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kattunga/subscriptions","organizations_url":"https://api.github.com/users/kattunga/orgs","repos_url":"https://api.github.com/users/kattunga/repos","events_url":"https://api.github.com/users/kattunga/events{/privacy}","received_events_url":"https://api.github.com/users/kattunga/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-21T13:52:31Z","updated_at":"2015-10-17T12:12:49Z","closed_at":"2015-10-17T12:12:49Z","body":"now if we try to cast a null value to any type of data an exception is raised:\r\n\r\n```pascal\r\nvar\r\n  doc: TJsonObject;\r\n  v: variant;\r\nbegin\r\n  doc := TJsonObject.Create;\r\n  try\r\n    doc['nullvalue'] := null;\r\n\r\n    // any of this raise an exception\r\n    v := doc['nullvalue'].Value;\r\n    v := doc['nullvalue'].IntValue;\r\n    v := doc['nullvalue'].LongValue;\r\n    v := doc['nullvalue'].FloatValue;\r\n    v := doc['nullvalue'].DateTimeValue;\r\n    v := doc['nullvalue'].BoolValue;\r\n\r\n  finally\r\n    doc.Free;\r\n  end;\r\nend;\r\n```\r\nWhy don't we cast nulls like if it is jdtNone?\r\n\r\nAlso DataSet fields cast nulls to required datatypes:\r\n```pascal\r\n  // if DataField.IsNull\r\n  v := DataField.AsString;  // this return empty string\r\n  v := DataField.AsInteger;  // this return 0\r\n  ...\r\n```\r\nAlso VarToString function:\r\n```pascal\r\n  v := VarToString(null);   // this return empty string\r\n```\r\n\r\nI would like to implement this but I like to ask you first.\r\n\r\nRegards\r\nChristian"}}