@@ -130,6 +130,49 @@ The simdjson library is found in...
130130<img src =" images/nodejs.jpg " width =" 20% " >
131131
132132
133+ ---
134+
135+ # Conventional JSON parsing (DOM)
136+
137+ Start with JSON.
138+ ``` json
139+ {"name" :" Scooby" , "age" : 3 , "friends" :[" Fred" , " Daphne" , " Velma" ]}
140+ ```
141+
142+ Parses (everything) to Document-Object-Model:
143+ <img src =" images/dom.svg " />
144+
145+ Copies to user data structure.
146+
147+
148+ ---
149+
150+ # Limitations of conventional parsing
151+
152+ - Tends to parse everything at once even when not needed.
153+ - Requires an intermediate data structure (DOM).
154+ - Can't specialize (e.g., treat ` "123" ` as a number)
155+
156+
157+ --
158+
159+ # On-Demand
160+
161+ Can load a multi-kilobyte file and only parse a narrow segment from an fast index.
162+
163+ ``` cpp
164+ #include < iostream>
165+ #include " simdjson.h"
166+ using namespace simdjson ;
167+ int main (void) {
168+ ondemand::parser parser;
169+ padded_string json = padded_string::load("twitter.json");
170+ ondemand::document tweets = parser.iterate(json);
171+ std::cout << uint64_t(tweets[ "search_metadata"] [ "count" ] ) << " results." << std::endl;
172+ }
173+ ```
174+
175+
133176---
134177
135178# Automate the serialization/deserialization process.
@@ -606,17 +649,6 @@ You might think "automatic = slow", but with simdjson + reflection:
606649The generated code is often * faster* than hand-written code!
607650
608651
609- ---
610-
611- # On-Demand: parse only what you need
612-
613- ``` cpp
614- auto car = doc[" Jean-Claude" ].get<Car>()
615- ```
616-
617- - Seeks ` ""Jean-Claude" ` with index, and then parses directly to ` Car ` .
618- - No intermediate, no extra parsing
619-
620652---
621653
622654# Real-World Benefits
0 commit comments