anchor.diff:              l |> List.iter (fun x -> a.JS.Push (encEl x) |> ignore)
               a)
   
  -    let Record (fields: (string * (obj -> obj))[]) =
  +    let Record (fields: (string * (obj -> obj) * OptionalFieldKind)[]) =
           box (fun (x: obj) ->
               let o = New []
  -            fields |> Array.iter (fun (name, enc) ->
  -                o?(name) <- enc x?(name))
  +            fields |> Array.iter (fun (name, enc, kind) ->
  +                match kind with
  +                | OptionalFieldKind.NotOption ->
  +                    o?(name) <- enc x?(name)
  +                | OptionalFieldKind.NormalOption ->
  +                    match x?(name) with
  +                    | Some x -> o?(name) <- x
  +                    | None -> ()
  +                | OptionalFieldKind.MarkedOption ->
  +                    if JS.HasOwnProperty x name then
  +                        o?(name) <- x?(name)
  +                | _ -> failwith "Invalid field option kind")
               o)
   
       let Array (encEl: 'T -> obj) =
  
positive.code:                 let fields =
                      FST.GetRecordFields(t, flags)
                      |> Array.map (fun f ->
                          WebSharper.Core.Json.Internal.GetName f, f.PropertyType)
                  ((fun es -> ok (call "Record" [J.NewArray es])), fields)
                  ||> Array.fold (fun k (n, t) ->
                      fun es ->
                          encode name call (T.FromType t) >>= fun e ->
                          k (J.NewArray [cString n; e] :: es))
                  <| []
              else
                  fail (name + ": Type not supported: " + t.FullName)
  
negative.code:         box (fun (a: obj[]) ->
              Set.ofArray(Array.map decEl a))
  
      let Record (fields: (string * (obj -> obj) * OptionalFieldKind)[]) =
          box (fun (x: obj) ->
              let o = New []
              fields |> Array.iter (fun (name, enc, kind) ->
                  match kind with
                  | OptionalFieldKind.NotOption ->
                      o?(name) <- enc x?(name)
                  | OptionalFieldKind.NormalOption ->
                      o?(name) <-
                          if JS.HasOwnProperty x name
                          then Some x?(name)
                          else None
                  | OptionalFieldKind.MarkedOption ->
                      if JS.HasOwnProperty x name then
                          o?(name) <- x?(name)
                  | _ -> failwith "Invalid field option kind")
              o)
  
      let Array decEl = Encode.Array decEl
  
  