@@ -373,25 +373,31 @@ module Standard = struct
373373 let json t =
374374 let stringlit s = `Stringlit (Yojson.Safe. to_string (`String s)) in
375375 `Assoc
376- [ " version" , `Intlit (string_of_int t.version)
377- ; " file" , stringlit (rewrite_path t.file)
378- ; ( " sourceRoot"
379- , stringlit
380- (match t.sourceroot with
381- | None -> " "
382- | Some s -> rewrite_path s) )
383- ; " names" , `List (List. map t.names ~f: (fun s -> stringlit s))
384- ; " sources" , `List (List. map t.sources ~f: (fun s -> stringlit (rewrite_path s)))
385- ; " mappings" , stringlit (Mappings. to_string t.mappings)
386- ; ( " sourcesContent"
387- , `List
388- (match t.sources_content with
389- | None -> []
390- | Some l ->
391- List. map l ~f: (function
392- | None -> `Null
393- | Some x -> Source_content. to_json x)) )
394- ]
376+ (List. filter_map
377+ ~f: (fun (name , v ) ->
378+ match v with
379+ | None -> None
380+ | Some v -> Some (name, v))
381+ [ " version" , Some (`Intlit (string_of_int t.version))
382+ ; " file" , Some (stringlit (rewrite_path t.file))
383+ ; ( " sourceRoot"
384+ , match t.sourceroot with
385+ | None -> None
386+ | Some s -> Some (stringlit (rewrite_path s)) )
387+ ; " names" , Some (`List (List. map t.names ~f: (fun s -> stringlit s)))
388+ ; ( " sources"
389+ , Some (`List (List. map t.sources ~f: (fun s -> stringlit (rewrite_path s)))) )
390+ ; " mappings" , Some (stringlit (Mappings. to_string t.mappings))
391+ ; ( " sourcesContent"
392+ , match t.sources_content with
393+ | None -> None
394+ | Some l ->
395+ Some
396+ (`List
397+ (List. map l ~f: (function
398+ | None -> `Null
399+ | Some x -> Source_content. to_json x))) )
400+ ])
395401
396402 let of_json (json : Yojson.Raw.t ) =
397403 match json with
0 commit comments