anchor.diff:          let sr = new StreamReader(stream, encoding, true, 1024, leaveOpen)
           let jsonReader = new JsonTextReader(sr) :> JsonReader
   
  +        let mutable currentValueIsNull = false
  +
           interface IPickleFormatReader with
               
               member __.BeginReadRoot (tag : string) =
  -                do jsonReader.ReadStartObject ()
  -
  -                jsonReader.ReadProperty "FsPickler"
  -                let version = jsonReader.ReadAs<string> ()
  -                if version <> AssemblyVersionInformation.Version then
  -                    raise <| new InvalidDataException(sprintf "Invalid FsPickler version %s." version)
  -
  -                jsonReader.ReadProperty "type"
  -                let id = jsonReader.ReadAs<string> ()
  -                if id <> tag then
  -                    let msg = sprintf "expected '%s' but was '%s'." tag id
  -                    raise <| new InvalidDataException()
  +                if jsonReader.ReadStartObject () then raise <| new InvalidDataException("root json element was null.")
  +                else
  +                    jsonReader.ReadProperty "FsPickler"
  +                    let version = jsonReader.ReadAs<string> ()
  +                    if version <> AssemblyVersionInformation.Version then
  +                        raise <| new InvalidDataException(sprintf "Invalid FsPickler version %s." version)
  +
  +                    jsonReader.ReadProperty "type"
  +                    let id = jsonReader.ReadAs<string> ()
  +                    if id <> tag then
  +                        let msg = sprintf "expected '%s' but was '%s'." tag id
  +                        raise <| new InvalidDataException()
   
               member __.EndReadRoot () = jsonReader.Read() |> ignore
   
               member __.BeginReadObject (_ : TypeInfo) (_ : PicklerInfo) (tag : string) =
                   jsonReader.ReadProperty tag
  -                jsonReader.ReadStartObject ()
  -                    
  -                let mutable objectFlags = ObjectFlags.None
  -                // temp solution ; this is wrong
  -                let mutable complete = false
  -
  -                while not complete do
  +
  +                if jsonReader.ReadStartObject () then 
  +                    currentValueIsNull <- true
  +                    ObjectFlags.IsNull
  +                else
  +                    let mutable objectFlags = ObjectFlags.None
  +
                       match jsonReader.ValueAs<string> () with
  -                    | "null" -> 
  -                        if jsonReader.ReadAs<bool> () then
  -                            objectFlags <- objectFlags ||| ObjectFlags.IsNull
  -                    | "isSubtype" ->
  -                        if jsonReader.ReadAs<bool> () then
  -                            objectFlags <- objectFlags ||| ObjectFlags.IsProperSubtype
                       | "cached" ->
                           if jsonReader.ReadAs<bool> () then
  -                            objectFlags <- objectFlags ||| ObjectFlags.IsCachedInstance
  +                            objectFlags <- ObjectFlags.IsCachedInstance
                       | "cyclic" ->
                           if jsonReader.ReadAs<bool> () then
  -                            objectFlags <- objectFlags ||| ObjectFlags.IsCyclicInstance
  +                            objectFlags <- ObjectFlags.IsCyclicInstance
                       | "sequence" ->
                           if jsonReader.ReadAs<bool> () then
  -                            objectFlags <- objectFlags ||| ObjectFlags.IsSequenceHeader
  -                    | _ -> 
  -                        complete <- true
  -
  -                objectFlags
  -
  -            member __.EndReadObject () = jsonReader.Read () |> ignore
  +                            objectFlags <- ObjectFlags.IsSequenceHeader
  +                    | _ -> ()
  +
  +                    match jsonReader.ValueAs<string> () with
  +                    | "subtype" ->
  +                        if jsonReader.ReadAs<bool> () then
  +                            objectFlags <- ObjectFlags.IsProperSubtype
  +                    | _ -> ()
  +
  +                    objectFlags
  +
  +            member __.EndReadObject () = 
  +                if currentValueIsNull then 
  +                    currentValueIsNull <- false
  +                else 
  +                    jsonReader.Read () |> ignore
   
               member __.ReadBoolean tag = jsonReader.ReadProperty tag ; jsonReader.ReadAs<bool> ()
   
  
positive.code: 
              member inline jsonReader.ValueAs<'T> () = jsonReader.Value |> fastUnbox<'T>
  
              member inline jsonReader.ReadStartObject () =
                  if jsonReader.Read() && jsonReader.TokenType = JsonToken.StartObject then
                      jsonReader.Read() |> ignore
                  else
                      raise <| new InvalidDataException("invalid json format.")
  
              member inline jsonReader.ReadEndObject () =
                  if jsonReader.Read() && jsonReader.TokenType = JsonToken.EndObject then ()
                  else
                      raise <| new InvalidDataException("invalid json format.")
  
              member inline jsonReader.ReadAs<'T> () = 
                  jsonReader.Read() |> ignore
  
negative.code:         let sw = new StreamWriter(stream, encoding, 1024, leaveOpen)
          let jsonWriter = new JsonTextWriter(sw) :> JsonWriter
          do jsonWriter.Formatting <- if indented then Formatting.Indented else Formatting.None
  
          let mutable currentValueIsNull = false
  
          interface IPickleFormatWriter with
              
  