1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! The JSON addon provides serialization and deserialization of ECS data to/from JSON.
//!
//! This addon enables converting component values, entities, and query results to JSON
//! strings, and parsing JSON back into component data. Entity identifiers, enumerations,
//! and bitmasks are encoded as strings for human readability.
//!
//! # Features
//!
//! - **Component Serialization**: Convert component data to JSON
//! - **Entity Serialization**: Serialize entities with all their components
//! - **Query Results**: Convert query results to JSON arrays
//! - **Deserialization**: Parse JSON strings into component values
//! - **Type Safety**: Leverages reflection metadata for accurate serialization
//!
//! # Usage
//!
//! Components must have reflection metadata (using `#[flecs(meta)]`) to be serialized:
//!
//! ```
//! use flecs_ecs::prelude::*;
//!
//! #[derive(Component)]
//! #[flecs(meta)]
//! struct Position {
//! x: f32,
//! y: f32,
//! }
//!
//! let world = World::new();
//!
//! // Create entity with Position
//! let entity = world.entity().set(Position { x: 10.0, y: 20.0 });
//!
//! // Serialize component to JSON
//! entity.get::<&Position>(|pos| {
//! let json = world.to_json::<Position>(pos);
//! println!("Position: {}", json);
//! // Output: Position: {"x":10, "y":20}
//! });
//!
//! // Serialize entire entity to JSON
//! let entity_json = entity.to_json(None);
//! println!("Entity: {}", entity_json);
//! // Output: Entity: {"name":"#123", "components":{"Position":{"x":10, "y":20}}}
//! ```
//!
//! # JSON Format
//!
//! For a detailed description of the JSON format used for serialization, including
//! how different types are encoded and the structure of serialized data, see the
//! [Flecs Remote API documentation](https://www.flecs.dev/flecs/md_docs_2FlecsRemoteApi.html).
//!
//! # Examples
//!
//! For comprehensive JSON serialization examples, see the [`examples/flecs/reflection/`]
//! directory, which includes:
//! - `reflection_basics_json.rs` - Basic JSON serialization
//! - `reflection_query_to_json.rs` - Serializing query results
//! - `reflection_query_to_custom_json.rs` - Custom JSON formatting
//! - `reflection_world_ser_deser.rs` - World serialization/deserialization
//!
//! [`examples/flecs/reflection/`]: https://github.com/Indra-db/Flecs-Rust/tree/main/flecs_ecs/examples/flecs/flecs/reflection
//!
//! # See also
//!
//! - [`World::to_json()`](crate::core::World::to_json) - Serialize component data to JSON
//! - [`EntityView::to_json()`](crate::core::EntityView::to_json) - Serialize entity to JSON
//! - [Flecs Remote API](https://www.flecs.dev/flecs/md_docs_2FlecsRemoteApi.html) - JSON format specification
//! - [`meta`](crate::addons::meta) - Reflection addon (required for JSON serialization)
/*
using from_json_desc_t = ecs_from_json_desc_t;
using entity_to_json_desc_t = ecs_entity_to_json_desc_t;
using iter_to_json_desc_t = ecs_iter_to_json_desc_t;
*/
use cratesys;
use FetchedId;
extern crate std;
extern crate alloc;
pub type FromJsonDesc = ecs_from_json_desc_t;
pub type WorldToJsonDesc = ecs_world_to_json_desc_t;
pub type EntityToJsonDesc = ecs_entity_to_json_desc_t;
pub type IterToJsonDesc = ecs_iter_to_json_desc_t;