package frama-c
Install
dune-project
Dependency
Authors
-
MMichele Alberti
-
TThibaud Antignac
-
GGergö Barany
-
PPatrick Baudin
-
TThibaut Benjamin
-
AAllan Blanchard
-
LLionel Blatter
-
FFrançois Bobot
-
RRichard Bonichon
-
QQuentin Bouillaguet
-
DDavid Bühler
-
ZZakaria Chihani
-
LLoïc Correnson
-
JJulien Crétin
-
PPascal Cuoq
-
ZZaynah Dargaye
-
BBasile Desloges
-
JJean-Christophe Filliâtre
-
PPhilippe Herrmann
-
MMaxime Jacquemin
-
FFlorent Kirchner
-
AAlexander Kogtenkov
-
TTristan Le Gall
-
JJean-Christophe Léchenet
-
MMatthieu Lemerre
-
DDara Ly
-
DDavid Maison
-
CClaude Marché
-
AAndré Maroneze
-
TThibault Martin
-
FFonenantsoa Maurica
-
MMelody Méaulle
-
BBenjamin Monate
-
YYannick Moy
-
PPierre Nigron
-
AAnne Pacalet
-
VValentin Perrelle
-
GGuillaume Petiot
-
DDario Pinto
-
VVirgile Prevosto
-
AArmand Puccetti
-
FFélix Ridoux
-
VVirgile Robles
-
JJan Rochel
-
MMuriel Roger
-
JJulien Signoles
-
NNicolas Stouls
-
KKostyantyn Vorobyov
-
BBoris Yakobowski
Maintainers
Sources
sha256=29612882330ecb6eddd0b4ca3afc0492b70d0feb3379a1b8e893194c6e173983
doc/frama-c.kernel/Frama_c_kernel/Json/index.html
Module Frama_c_kernel.Json
Json Library
Remarks:
- UTF-8 escaping is not supported;
- Parsers are less strict than Json format;
- Printers are supposed to strictly conforms to Json format;
Numbercan be used to encode non OCaml-primitive numbers, for instance Zarith.
type json = [ | `Assoc of (string * json) list| `Bool of bool| `Float of float| `Int of int| `List of json list| `Null| `String of string
]Json Objects
Same type than Yojson.Basic.json
type t = jsonval pp : Format.formatter -> t -> unitval pp_dump : Format.formatter -> t -> unitwithout formatting
exception Error of Filepath.Normalized.t * int * stringfile, line, message
Constructors
val of_bool : bool -> tval of_int : int -> tval of_string : string -> tval of_float : float -> tParsers
Parsing raise Error in case of error.
val load_lexbuf : Lexing.lexbuf -> tConsumes the entire buffer.
val load_channel : ?file:string -> in_channel -> tParses the stream until EOF.
val load_string : string -> tParses the Json in the string.
val load_file : Filepath.Normalized.t -> tMay also raise system exception.
Printers
Printers use formatting unless ~pretty:false.
val save_string : ?pretty:bool -> t -> stringval save_channel : ?pretty:bool -> out_channel -> t -> unitval save_formatter : ?pretty:bool -> Format.formatter -> t -> unitval save_file : ?pretty:bool -> Filepath.Normalized.t -> t -> unitAccessors
Accessors raise exception Invalid_argument in case of wrong format.
val bool : t -> boolExtract True and False only.
val int : t -> intConvert Null, Int, Float, Number and String to an int. Floats are truncated with int_of_float and Null to 0.
val string : t -> stringConvert Null, Int, Float, Number and String to a string. Floats are truncated with string_of_float and Null to "".
val float : t -> floatConvert Null, Int, Float, Number and String to float and Null to 0.0.
Extract the list of an Assoc object. Null is considered an empty assoc.
Fold over all fields of the object. Null is considered an empty object. Typical usage is fold M.add t M.empty where M=Map.Make(String).
The functions below read and write to JSON files asynchronously; they are intended to be called at different times during execution. To avoid reopening, re-reading and rewriting the same file several times, they instead operate as following:
- Read the file on first use, and store it in memory;
- Perform merge operations using the in-memory representations;
- Flush the final form to disk before quitting Frama-C. The latter is done via function
json_flush_cachebelow, which is setup to run with anat_exittrigger.
Note: no other functions should modify the contents of path; any modifications will be overwritten when the cache is flushed.
Exception raised by the functions below when incompatible types are merged.
val merge_object : Filepath.Normalized.t -> t -> unitmerge_object path json_obj recursively merges the object json_obj into the JSON file path. If path does not exist, it is created. Merge consists in combining values with the same key, e.g. if path already contains an object {"kernel": {"options": ["a"]}}, and json_obj is {"kernel": {"options": ["b"]}}, the result will be {"kernel": {"options": ["a", "b"]}}. Cannot merge heterogeneous objects, i.e. in the previous example, if "options" were associated with a string in path, trying to merge an array into it would raise CannotMerge. The merged object is updated in the memory cache.
val merge_array : Filepath.Normalized.t -> t -> unitmerge_list path json_array merges the array json_array into the JSON file path. See merge_object for more details. Unlike objects, arrays are merged by simply concatenating their list of elements.
val from_file : Filepath.Normalized.t -> tfrom_file path opens path and stores its JSON object in a memory cache, to be used by the other related functions.
val flush_cache : unit -> Filepath.Normalized.t listFlushes the JSON objects in the cache. Returns the names of the written files.