{"action":"created","issue":{"url":"https://api.github.com/repos/nessos/FsPickler/issues/41","labels_url":"https://api.github.com/repos/nessos/FsPickler/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/nessos/FsPickler/issues/41/comments","events_url":"https://api.github.com/repos/nessos/FsPickler/issues/41/events","html_url":"https://github.com/nessos/FsPickler/issues/41","id":66691482,"number":41,"title":"Questions about \"_flags\"","user":{"login":"GoodGuyJim","id":9199036,"avatar_url":"https://avatars.githubusercontent.com/u/9199036?v=3","gravatar_id":"","url":"https://api.github.com/users/GoodGuyJim","html_url":"https://github.com/GoodGuyJim","followers_url":"https://api.github.com/users/GoodGuyJim/followers","following_url":"https://api.github.com/users/GoodGuyJim/following{/other_user}","gists_url":"https://api.github.com/users/GoodGuyJim/gists{/gist_id}","starred_url":"https://api.github.com/users/GoodGuyJim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoodGuyJim/subscriptions","organizations_url":"https://api.github.com/users/GoodGuyJim/orgs","repos_url":"https://api.github.com/users/GoodGuyJim/repos","events_url":"https://api.github.com/users/GoodGuyJim/events{/privacy}","received_events_url":"https://api.github.com/users/GoodGuyJim/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-06T19:53:32Z","updated_at":"2015-04-07T08:25:35Z","closed_at":null,"body":"Hey there, just had two quick questions about how certain things in my Pickled JSON end up as an object that looks like:\r\n\r\n`{ \"_flags\": \"cached\", \"id\": 45 }`\r\n\r\nIs that some form of JSON compression? \r\nIf so, is there any way to return the uncompressed JSON without attempting to convert it to the type that was used to make it in the first place?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/nessos/FsPickler/issues/comments/90457556","html_url":"https://github.com/nessos/FsPickler/issues/41#issuecomment-90457556","issue_url":"https://api.github.com/repos/nessos/FsPickler/issues/41","id":90457556,"user":{"login":"eiriktsarpalis","id":2813363,"avatar_url":"https://avatars.githubusercontent.com/u/2813363?v=3","gravatar_id":"","url":"https://api.github.com/users/eiriktsarpalis","html_url":"https://github.com/eiriktsarpalis","followers_url":"https://api.github.com/users/eiriktsarpalis/followers","following_url":"https://api.github.com/users/eiriktsarpalis/following{/other_user}","gists_url":"https://api.github.com/users/eiriktsarpalis/gists{/gist_id}","starred_url":"https://api.github.com/users/eiriktsarpalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eiriktsarpalis/subscriptions","organizations_url":"https://api.github.com/users/eiriktsarpalis/orgs","repos_url":"https://api.github.com/users/eiriktsarpalis/repos","events_url":"https://api.github.com/users/eiriktsarpalis/events{/privacy}","received_events_url":"https://api.github.com/users/eiriktsarpalis/received_events","type":"User","site_admin":false},"created_at":"2015-04-07T08:25:35Z","updated_at":"2015-04-07T08:25:35Z","body":"Ok, that's pretty interesting. If it helps, there are a few ways with which you can reduce the chance of identical objects appearing in an object graph. Given that you are using EventStore I would imagine that you are persisting small, immutable objects. So here's a few points:\r\n* Do you serialize each of the events independently or do you serialize a whole collection of them at once? This can make a big difference since you are containing serialization state to smaller object graphs. In case of the same event (up to reference equality) appearing in the list you would avoid it being \"cached\".\r\n* Do your events capture singleton objects? The usual suspects are instances of `System.Type` or user-defined entities. \r\n* Does your domain modelling rely on subtyping and inheritance? If your persisted event type is an abstract class that is being inherited by many concrete implementations then FsPickler will compensate by serializing reflection data, which may often be \"cached\". A common remedy is to use F# discriminated unions instead.\r\n\r\nFinally, here's an example that illustrates when and how this caching behaviour kicks in:\r\n```fsharp\r\nlet jsp = FsPickler.CreateJson(indent = false, omitHeader = true)\r\n\r\nlet v1 = let x = [1..10] in x,x\r\nlet v2 = [1..10], [1..10]\r\n\r\njsp.PickleToString v1\r\njsp.PickleToString v2\r\n```\r\nThe two values are structurally identical, however they will produce different serializations, the first yielding\r\n```json\r\n{\"Item1\":[1,2,3,4,5,6,7,8,9,10],\"Item2\":{\"_flags\":\"cached\",\"id\":2}}\r\n```\r\nand the second\r\n```json\r\n{\"Item1\":[1,2,3,4,5,6,7,8,9,10],\"Item2\":[1,2,3,4,5,6,7,8,9,10]}\r\n```\r\n\r\nI realize that you probably need to work with data that has already been serialized, so these points might not make much of a difference to you."}}