Skip to content

Commit 749bd5d

Browse files
committed
[Serializer] Add streaming JSON documentation
1 parent 5147f15 commit 749bd5d

File tree

2 files changed

+700
-0
lines changed

2 files changed

+700
-0
lines changed

serializer.rst

+32
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,38 @@ all the properties of the class::
629629
// ...
630630
}
631631

632+
Serializing JSON using streams
633+
------------------------------
634+
635+
Symfony is able of encoding PHP data structures to JSON streams and decoding
636+
JSON streams back into PHP data structures.
637+
638+
To do so, it relies on the JsonStreamer component, which is designed for high
639+
efficiency and can process large JSON data incrementally without needing to
640+
load the entire content into memory.
641+
642+
When deciding between the :doc:`Serializer component <serializer>` and the
643+
JsonStreamer component, consider the following:
644+
645+
- **Serializer Component**: Ideal for scenarios requiring flexibility, such as
646+
dynamically manipulating object shapes using normalizers and denormalizers,
647+
or handling complex objects which multiple serialization representation.
648+
Plus, it allows working with formats beyond JSON (and even with a custom
649+
format of yours).
650+
651+
- **JsonStreamer Component**: Ideal for simple objects and tasks that
652+
demand high performance and minimal memory usage. It's particularly
653+
effective when processing very large JSON datasets or in scenarios that
654+
require streaming JSON in real-time without loading the entire dataset
655+
into memory.
656+
657+
Choosing between the two depends on your specific use case requirements.
658+
The JsonStreamer component is tailored to optimize for performance and memory
659+
efficiency, while the Serializer component offers flexibility and broader
660+
format support.
661+
662+
Read more about streaming JSON in :doc:`/serializer/streaming_json`.
663+
632664
Serializing to or from PHP Arrays
633665
---------------------------------
634666

0 commit comments

Comments
 (0)