1a1d56debSopenharmony_ci// Copyright (c) 2023 Huawei Device Co., Ltd. 2a1d56debSopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 3a1d56debSopenharmony_ci// you may not use this file except in compliance with the License. 4a1d56debSopenharmony_ci// You may obtain a copy of the License at 5a1d56debSopenharmony_ci// 6a1d56debSopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 7a1d56debSopenharmony_ci// 8a1d56debSopenharmony_ci// Unless required by applicable law or agreed to in writing, software 9a1d56debSopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 10a1d56debSopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11a1d56debSopenharmony_ci// See the License for the specific language governing permissions and 12a1d56debSopenharmony_ci// limitations under the License. 13a1d56debSopenharmony_ci 14a1d56debSopenharmony_ci//! ylong_json is a library for parsing and serializing JSON in Rust. 15a1d56debSopenharmony_ci//! This library provides a convenient macro-based API for creating 16a1d56debSopenharmony_ci//! JSON values, and utilities for reading and writing JSON data 17a1d56debSopenharmony_ci//! from various sources. 18a1d56debSopenharmony_ci 19a1d56debSopenharmony_ci// TODO: 1) Isolates ylong_json no_std. 20a1d56debSopenharmony_ci// TODO: 2) Handles illegal Utf-8 bytes. 21a1d56debSopenharmony_ci// TODO: 3) Refactors ylong_json. 22a1d56debSopenharmony_ci// TODO: 4) JsonValue provides 'Contains' methods。 23a1d56debSopenharmony_ci 24a1d56debSopenharmony_ci/// Creates an array with at least one but any number of elements. 25a1d56debSopenharmony_ci#[macro_export] 26a1d56debSopenharmony_cimacro_rules! array { 27a1d56debSopenharmony_ci () => ({ 28a1d56debSopenharmony_ci Array::new() 29a1d56debSopenharmony_ci }); 30a1d56debSopenharmony_ci ($($x:expr),+ $(,)?) => ({ 31a1d56debSopenharmony_ci let mut array = Array::new(); 32a1d56debSopenharmony_ci $( 33a1d56debSopenharmony_ci array.push($x.into()); 34a1d56debSopenharmony_ci )* 35a1d56debSopenharmony_ci array 36a1d56debSopenharmony_ci }); 37a1d56debSopenharmony_ci} 38a1d56debSopenharmony_ci 39a1d56debSopenharmony_ci/// Creates an object with at least one but any number of key-value pairs. 40a1d56debSopenharmony_ci#[macro_export] 41a1d56debSopenharmony_cimacro_rules! object { 42a1d56debSopenharmony_ci () => ({ 43a1d56debSopenharmony_ci Object::new() 44a1d56debSopenharmony_ci }); 45a1d56debSopenharmony_ci ($($k: expr => $v: expr);+ $(;)?) => ({ 46a1d56debSopenharmony_ci let mut object = Object::new(); 47a1d56debSopenharmony_ci $( 48a1d56debSopenharmony_ci object.insert(String::from($k), $v.into()); 49a1d56debSopenharmony_ci )* 50a1d56debSopenharmony_ci object 51a1d56debSopenharmony_ci }); 52a1d56debSopenharmony_ci} 53a1d56debSopenharmony_ci 54a1d56debSopenharmony_cimod consts; 55a1d56debSopenharmony_cimod encoder; 56a1d56debSopenharmony_cimod error; 57a1d56debSopenharmony_cimod reader; 58a1d56debSopenharmony_ci#[macro_use] 59a1d56debSopenharmony_cimod states; 60a1d56debSopenharmony_cimod value; 61a1d56debSopenharmony_ci 62a1d56debSopenharmony_cipub use error::{Error, ParseError}; 63a1d56debSopenharmony_cipub use value::{Array, Index, JsonValue, Number, Object}; 64a1d56debSopenharmony_ci 65a1d56debSopenharmony_cipub(crate) use encoder::{CompactEncoder, FormattedEncoder}; 66a1d56debSopenharmony_cipub(crate) use states::start_parsing; 67a1d56debSopenharmony_ci 68a1d56debSopenharmony_ci#[cfg(feature = "c_adapter")] 69a1d56debSopenharmony_cimod adapter; 70a1d56debSopenharmony_ci#[cfg(feature = "c_adapter")] 71a1d56debSopenharmony_cipub use adapter::*; 72a1d56debSopenharmony_ci 73a1d56debSopenharmony_cimod deserializer; 74a1d56debSopenharmony_ci#[cfg(any(feature = "list_array", feature = "list_object"))] 75a1d56debSopenharmony_cimod linked_list; 76a1d56debSopenharmony_cimod serializer_compact; 77a1d56debSopenharmony_ci 78a1d56debSopenharmony_ci#[cfg(any(feature = "list_array", feature = "list_object"))] 79a1d56debSopenharmony_cipub(crate) use linked_list::{Cursor, CursorMut, LinkedList}; 80a1d56debSopenharmony_ci#[cfg(any(feature = "list_array", feature = "list_object"))] 81a1d56debSopenharmony_cipub use linked_list::{Iter, IterMut, Node}; 82a1d56debSopenharmony_ci 83a1d56debSopenharmony_cipub use deserializer::{from_reader, from_slice, from_str}; 84a1d56debSopenharmony_cipub use serializer_compact::{to_string, to_writer}; 85