This patch series replaces the text format parser used for search in Emacs with a parser for the JSON format. This should address the escaping and flexibility problems that have plagued the text format. Like the text format, it supports incremental output. Patches 1-4 simply clean up the Emacs search code and could be pushed before the rest of the series. Patch 5 switches to the JSON plist representation internally, but retains the text parser. This requires some changes to the text parser to keep things working, but don't get too hung up on them since it's about to get replaced entirely. Patch 6 adds a test. Finally, patches 7 and 8 are the real meat. Patch 7 introduces a general incremental JSON parser. For search, we could probably get away with a simpler, hacky approach, but an incremental JSON parser is the type of thing you only want to write once---hacky or not---and it seems like the type of thing that could be useful elsewhere, too. It's general enough to support things like incremental show buffer rendering. Patch 8 rewrites the search output parser to use the JSON format via this incremental parser.