View Source euneus_formatter (euneus v1.2.2)

JSON formatter.

Copyright 2023 William Fank Thomé

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.



-type input() :: binary() | iolist().
-type options() ::
    #{spaces => binary() | non_neg_integer(),
      indent => binary() | non_neg_integer(),
      crlf => binary() | cr | lf | crlf}.
-type parsed_options() :: #opts{}.
-type result() :: iolist().


-spec format(input(), options()) -> result().
Format JSON.
Link to this function

format_parsed(JSON, Opts)

View Source
-spec format_parsed(input(), parsed_options()) -> result().
Format JSON.

See also: euneus_formatter:parse_opts/1.

-spec minify(input()) -> result().
Remove extra spaces and line feeds from JSON.

See also: euneus_formatter:format_parsed/2.

-spec parse_opts(options()) -> parsed_options().

Parses euneus_formatter:options() to euneus_formatter:parsed_options().

The parsed map can be expanded in compile time or stored to be reused, avoiding parsing the options in every encoding.
-spec prettify(input()) -> result().
Format JSON for printing.

See also: euneus_formatter:format_parsed/2.