@@ -400,7 +400,78 @@ As mentioned earlier, `Writer` can handle the events published by `Reader`. `con
...
@@ -400,7 +400,78 @@ As mentioned earlier, `Writer` can handle the events published by `Reader`. `con
Actually, we can add intermediate layer(s) to filter the contents of JSON via these SAX-style API. For example, `capitalize` example capitalize all strings in a JSON.
Actually, we can add intermediate layer(s) to filter the contents of JSON via these SAX-style API. For example, `capitalize` example capitalize all strings in a JSON.
Note that, it is incorrect to simply capitalize the JSON as a string. For example:
~~~~~~~~~~js
["Hello\\nWorld"]
~~~~~~~~~~
Simply capitalizing the whole JSON would contain incorrect escape character:
~~~~~~~~~~js
["HELLO\\NWORLD"]
~~~~~~~~~~
The correct result by `capitalize`:
~~~~~~~~~~js
["HELLO\\nWORLD"]
~~~~~~~~~~
~~~~~~~~~~
More complicated filters can be developed. However, since SAX-style API can only provide information about a single event at a time, user may need to book-keeping the contextual information (e.g. the path from root value, storage of other related values). Some processing may be easier to be implemented in DOM than SAX.
More complicated filters can be developed. However, since SAX-style API can only provide information about a single event at a time, user may need to book-keeping the contextual information (e.g. the path from root value, storage of other related values). Some processing may be easier to be implemented in DOM than SAX.