Docs.rs
  • json-syntax-0.12.5
    • json-syntax 0.12.5
    • Permalink
    • Docs.rs crate page
    • MIT/Apache-2.0
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • timothee-haudebourg
    • Dependencies
      • contextual ^0.1.1 normal optional
      • decoded-char ^0.1 normal
      • hashbrown ^0.12.1 normal
      • indexmap ^1.9.1 normal
      • json-number ^0.4.8 normal
      • locspan ^0.8.2 normal
      • locspan-derive ^0.6 normal
      • ryu-js ^0.2.2 normal optional
      • serde ^1.0 normal optional
      • serde_json ^1.0 normal optional
      • smallstr ^0.3 normal
      • smallvec ^1.9 normal
      • utf8-decode ^1.0.1 normal
      • serde ^1.0 dev
    • Versions
    • 38.15% of the crate is documented
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate json_syntax

json_syntax0.12.5

  • All Items

Sections

  • Features
  • Usage

Crate Items

  • Re-exports
  • Modules
  • Macros
  • Structs
  • Enums
  • Constants
  • Traits
  • Functions
  • Type Aliases

Crates

  • json_syntax

Crate json_syntax

Source
Expand description

This library provides a strict JSON parser as defined by RFC 8259 and ECMA-404. Parsing values generates a CodeMap that keeps track of the position of each JSON value fragment in the parsed document.

§Features

  • Strict implementation of RFC 8259 and ECMA-404.
  • No stack overflow, your memory is the limit.
  • Numbers are stored in lexical form thanks to the json-number crate, their precision is not limited.
  • Duplicate values are preserved. A JSON object is just a list of entries, in the order of definition.
  • Strings are stored on the stack whenever possible, thanks to the smallstr crate.
  • The parser is configurable to accept documents that do not strictly adhere to the standard.
  • Highly configurable printing methods.
  • Macro to build any value statically.
  • JSON Canonicalization Scheme implementation (RFC 8785) enabled with the canonicalization feature.
  • serde support (by enabling the serde feature).
  • Conversion from/to serde_json::Value (by enabling the serde_json feature).
  • Thoroughly tested.

§Usage

use std::fs;
use json_syntax::{Value, Parse, Print};

let filename = "tests/inputs/y_structure_500_nested_arrays.json";
let input = fs::read_to_string(filename).unwrap();
let mut value = Value::parse_str(&input).expect("parse error").0;
println!("value: {}", value.pretty_print());

Re-exports§

pub use code_map::CodeMap;
pub use parse::Parse;
pub use print::Print;
pub use kind::Kind;
pub use kind::KindSet;
pub use array::Array;
pub use object::Object;

Modules§

array
code_map
kind
JSON value kinds.
number
object
parse
print

Macros§

json
Constructs a json_syntax::Value from a JSON literal.

Structs§

InvalidNumber
Invalid number error.
KeySerializer
Number
Lexical JSON number.
NumberType
SerializeArray
SerializeStructVariant
SerializeTupleVariant
Serializer
Value serializer.
StringNumberSerializer
Traverse
Unexpected
Unexpected JSON value kind error.
Unordered
Wrapper to view a value without considering the order of the objects entries.

Enums§

DeserializeError
FragmentRef
SerializeError
SerializeMap
SubFragments
TryIntoNumberError
Value
JSON Value.

Constants§

NUMBER_CAPACITY
Number buffer stack capacity.
SMALL_STRING_CAPACITY
String stack capacity.

Traits§

BorrowUnordered
TryFromJson
Conversion from JSON syntax, with code mapping info.
TryFromJsonObject
Conversion from JSON syntax object, with code mapping info.
UnorderedEq
UnorderedHash
UnorderedPartialEq

Functions§

from_value
Deserializes the JSON value into an instance of type T.
get_array_fragment
to_value
Serializes the given value into a JSON Value.

Type Aliases§

NumberBuf
Number buffer.
String
String.

Results

Settings
Help
    struct
    json_syntax::object::Object
    Object.
    enum variant
    json_syntax::Value::Object
    Object.
    module
    json_syntax::object
    enum variant
    json_syntax::SerializeMap::Object
    enum variant
    json_syntax::SubFragments::Object
    enum variant
    json_syntax::kind::Kind::Object
    assoc const
    json_syntax::kind::KindSet::OBJECT
    enum variant
    json_syntax::parse::Context::ObjectKey
    struct field
    json_syntax::print::Options::object_end
    String added before }.
    enum variant
    json_syntax::parse::Context::ObjectValue
    struct field
    json_syntax::print::Options::object_begin
    String added after {.
    struct field
    json_syntax::print::Options::object_empty
    Number of spaces inside an inlined empty object.
    struct field
    json_syntax::print::Options::object_limit
    Limit after which an array is expanded.
    struct field
    json_syntax::print::Options::object_after_colon
    Number of spaces after a colon in an object.
    struct field
    json_syntax::print::Options::object_after_comma
    Number of spaces after a comma in an object.
    struct field
    json_syntax::print::Options::object_before_colon
    Number of spaces before a colon in an object.
    struct field
    json_syntax::print::Options::object_before_comma
    Number of spaces before a comma in an object.
    method
    json_syntax::Value::as_object
    method
    json_syntax::FragmentRef::is_object
    method
    json_syntax::Value::is_object
    method
    json_syntax::Value::as_object_mut
    method
    json_syntax::Value::into_object
    function
    json_syntax::print::print_object
    function
    json_syntax::print::pre_compute_object_size
    trait
    json_syntax::TryFromJsonObject
    Conversion from JSON syntax object, with code mapping info.
    method
    json_syntax::TryFromJsonObject::try_from_json_object
    Tries to convert the given JSON object into Self, using …
    trait method
    json_syntax::TryFromJsonObject::try_from_json_object_at
    Tries to convert the given JSON object into Self, using …
    method
    json_syntax::Value::is_empty_array_or_object
    Checks if the value is either an empty array or an empty …
    struct field
    json_syntax::SerializeMap::Object::obj
    Object -> Object
    method
    json_syntax::Value::from
    Object -> Value
    struct field
    json_syntax::SerializeMap::Object::next_key
    Object -> Option
    method
    json_syntax::object::Object::into_iter
    Object -> IntoIterator::IntoIter
    method
    json_syntax::object::Object::into_deserializer
    Object -> IntoDeserializer::Deserializer
    method
    json_syntax::object::Object::len
    &Object -> usize
    method
    json_syntax::object::Object::iter
    &Object -> Iter
    method
    json_syntax::object::Object::clone
    &Object -> Object
    method
    json_syntax::object::Object::capacity
    &Object -> usize
    method
    json_syntax::object::Object::is_empty
    &Object -> bool
    method
    json_syntax::object::Object::sort
    &mut Object -> ()
    Sort the entries by key name.
    method
    json_syntax::object::Object::iter_mut
    &mut Object -> IterMut
    method
    json_syntax::object::Object::canonicalize
    &mut Object -> ()
    Puts this JSON object in canonical form according to RFC …
    method
    json_syntax::object::Object::eq
    &Object, &Object -> bool
    method
    json_syntax::object::Object::cmp
    &Object, &Object -> Ordering
    method
    json_syntax::object::Object::last
    &Object -> Option<&Entry>
    method
    json_syntax::object::Object::first
    &Object -> Option<&Entry>
    method
    json_syntax::object::Object::entries
    &Object -> &[Entry]
    method
    json_syntax::object::Object::serialize
    &Object, S -> Result
    method
    json_syntax::object::Object::push_entry
    &mut Object, Entry -> bool
    method
    json_syntax::object::Object::unordered_eq
    &Object, &Object -> bool
    method
    json_syntax::object::Object::push_entry_front
    &mut Object, Entry -> bool
    method
    json_syntax::object::Object::fmt
    &Object, &mut Formatter -> Result
    method
    json_syntax::object::Object::push
    &mut Object, Key, Value -> bool
    Push the given key-value pair to the end of the object.
    method
    json_syntax::object::Object::remove_at
    &mut Object, usize -> Option<Entry>
    Removes the entry at the given index.
    method
    json_syntax::object::Object::push_front
    &mut Object, Key, Value -> bool
    Push the given key-value pair to the top of the object.
    method
    json_syntax::object::Object::iter_mapped
    &Object, &CodeMap, usize -> IterMapped
    method
    json_syntax::object::Object::partial_cmp
    &Object, &Object -> Option<Ordering>
    method
    json_syntax::object::Object::get_fragment
    &Object, usize -> Result<FragmentRef, usize>
    method
    json_syntax::object::Object::insert_front
    &mut Object, Key, Value -> RemovedByInsertFront
    Inserts the given key-value pair on top of the object.
    method
    json_syntax::object::Object::hash
    &Object, &mut H -> ()
    method
    json_syntax::object::Object::insert
    &mut Object, Key, Value -> Option<RemovedByInsertion>
    Inserts the given key-value pair.
    method
    json_syntax::object::Object::canonicalize_with
    &mut Object, &mut Buffer -> ()
    Puts this JSON object in canonical form according to RFC …
    method
    json_syntax::object::Object::extend
    &mut Object, I -> ()
    method
    json_syntax::object::Object::get
    &Object, &Q -> Values
    Returns an iterator over the values matching the given key.
    method
    json_syntax::object::Object::indexes_of
    &Object, &Q -> Indexes
    method
    json_syntax::object::Object::get_entries
    &Object, &Q -> Entries
    Returns an iterator over the entries matching the given …
    method
    json_syntax::object::Object::contains_key
    &Object, &Q -> bool
    Checks if this object contains the given key.
    method
    json_syntax::object::Object::get_with_index
    &Object, &Q -> ValuesWithIndex
    Returns an iterator over the values matching the given key.
    method
    json_syntax::TryFromJsonObject::try_from_json_object
    &Object, &CodeMap -> Result<TryFromJsonObject, TryFromJsonObject::Error>
    Tries to convert the given JSON object into Self, using …
    method
    json_syntax::object::Object::get_entries_with_index
    &Object, &Q -> EntriesWithIndex
    Returns an iterator over the entries matching the given …
    method
    json_syntax::object::Object::get_mut
    &mut Object, &Q -> ValuesMut
    Returns an iterator over the values matching the given key.
    method
    json_syntax::object::Object::index_of
    &Object, &Q -> Option<usize>
    method
    json_syntax::object::Object::redundant_index_of
    &Object, &Q -> Option<usize>
    trait method
    json_syntax::TryFromJsonObject::try_from_json_object_at
    &Object, &CodeMap, usize -> Result<TryFromJsonObject, TryFromJsonObject::Error>
    Tries to convert the given JSON object into Self, using …
    method
    json_syntax::object::Object::remove
    &mut Object, &Q -> RemovedEntries<Q>
    Remove all entries associated to the given key.
    method
    json_syntax::object::Object::get_mapped
    &Object, &CodeMap, usize, &Q -> MappedValues
    Returns an iterator over the mapped values matching the …
    method
    json_syntax::object::Object::get_mapped_entries
    &Object, &CodeMap, usize, &Q -> MappedEntries
    Returns an iterator over the mapped entries matching the …
    method
    json_syntax::object::Object::get_mapped_with_index
    &Object, &CodeMap, usize, &Q -> MappedValuesWithIndex
    Returns an iterator over the mapped values matching the …
    method
    json_syntax::object::Object::get_mapped_entries_with_index
    &Object, &CodeMap, usize, &Q -> MappedEntriesWithIndex
    Returns an iterator over the mapped entries matching the …
    method
    json_syntax::object::Object::remove_unique
    &mut Object, &Q -> Result<Option<Entry>, Duplicate<Entry>>
    Remove the unique entry associated to the given key.
    method
    json_syntax::object::Object::get_unique
    &Object, &Q -> Result<Option<&Value>, Duplicate<&Entry>>
    Returns the unique entry value matching the given key.
    method
    json_syntax::object::Object::fmt_with_size
    &Object, &mut Formatter, &Options, usize, &[Size], &mut usize -> Result
    method
    json_syntax::object::Object::get_unique_entry
    &Object, &Q -> Result<Option<&Entry>, Duplicate<&Entry>>
    Returns the unique entry matching the given key.
    method
    json_syntax::object::Object::get_or_insert_with
    &mut Object, &Q, undefined -> &Value
    Returns the (first) value associated to key, or insert a …
    method
    json_syntax::object::Object::get_unique_mapped_entry
    &Object, &CodeMap, usize, &Q -> Result<Option<MappedEntry>, Duplicate<MappedEntry>>
    Returns the unique mapped entry matching the given key.
    method
    json_syntax::object::Object::get_unique_mapped_with_index
    &Object, &CodeMap, usize, &Q -> Result<Option<IndexedMappedValue>, Duplicate<IndexedMappedValue>>
    Returns the unique mapped values matching the given key, …
    method
    json_syntax::object::Object::get_unique_mapped_entry_with_index
    &Object, &CodeMap, usize, &Q -> Result<Option<IndexedMappedEntry>, Duplicate<IndexedMappedEntry>>
    Returns the unique mapped entry matching the given key, …
    method
    json_syntax::object::Object::get_unique_mut
    &mut Object, &Q -> Result<Option<&mut Value>, Duplicate<&Entry>>
    Returns the unique entry value matching the given key.
    method
    json_syntax::object::Object::get_mut_or_insert_with
    &mut Object, &Q, undefined -> &mut Value
    Returns a mutable reference to the (first) value …
    method
    json_syntax::object::Object::get_unique_mapped
    &Object, &CodeMap, usize, &Q -> Result<Option<Mapped<&Value>>, Duplicate<Mapped<&Value>>>
    Returns the unique mapped values matching the given key.
    method
    json_syntax::object::Object::new
    -> Object
    method
    json_syntax::object::Object::default
    -> Object
    method
    json_syntax::object::Object::from
    Vec<Entry> -> Object
    method
    json_syntax::object::Object::from_vec
    Vec<Entry> -> Object
    method
    json_syntax::Value::into_object
    Value -> Option<Object>
    method
    json_syntax::object::Object::deserialize
    D -> Result<Object>
    method
    json_syntax::Value::as_object
    &Value -> Option<&Object>
    method
    json_syntax::object::Object::from_iter
    I -> Object
    method
    json_syntax::Value::as_object_mut
    &mut Value -> Option<&mut Object>
    struct field
    json_syntax::SerializeMap::Object::obj
    Object -> Object
    method
    json_syntax::object::Object::clone
    &Object -> Object