MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / WriteInspectionResultJson

Function WriteInspectionResultJson

src/tools/CommandLineMain.cpp:323–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321// for nested pipeline stages.
322template <typename Writer>
323void WriteInspectionResultJson(Writer& writer,
324 const ConversionInspectionResult& result) {
325 writer.StartObject();
326 writer.Key("input");
327 writer.String(result.input.c_str(), result.input.size());
328 writer.Key("segments");
329 writer.StartArray();
330 for (const auto& seg : result.segments) {
331 writer.String(seg.c_str(), seg.size());
332 }
333 writer.EndArray();
334 writer.Key("stages");
335 writer.StartArray();
336 for (const auto& stage : result.stages) {
337 writer.StartObject();
338 writer.Key("index");
339 writer.Uint64(stage.index);
340 writer.Key("segments");
341 writer.StartArray();
342 for (const auto& seg : stage.segments) {
343 writer.String(seg.c_str(), seg.size());
344 }
345 writer.EndArray();
346 writer.EndObject();
347 }
348 writer.EndArray();
349 writer.Key("pipelineStages");
350 writer.StartArray();
351 for (const auto& ps : result.pipelineStages) {
352 WriteInspectionResultJson(writer, ps);
353 }
354 writer.EndArray();
355 writer.Key("output");
356 writer.String(result.output.c_str(), result.output.size());
357 writer.EndObject();
358}
359
360// Serializes the full inspection result as a JSON object. Used with
361// --inspect mode. Handles both single-stage and pipeline converters.

Callers 1

Calls 8

StartObjectMethod · 0.45
KeyMethod · 0.45
StringMethod · 0.45
sizeMethod · 0.45
StartArrayMethod · 0.45
EndArrayMethod · 0.45
Uint64Method · 0.45
EndObjectMethod · 0.45

Tested by

no test coverage detected