Implementation:Alibaba MNN FlatBuffers IDL Gen Text
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Serialization, Code_Generation |
| Last Updated | 2026-02-10 12:00 GMT |
Overview
JSON text generator that converts binary FlatBuffer data back into human-readable JSON using the schema.
Description
idl_gen_text.cpp implements a text output generator that serializes binary FlatBuffer data into JSON format. Given a binary buffer and its corresponding parsed schema, it walks the FlatBuffer structure and emits formatted JSON with proper indentation. This is used by flatc for the --json output mode and is essential for debugging and inspecting binary FlatBuffer files.
Usage
Vendored dependency used internally by MNN for model serialization. Not directly imported by end users.
Code Reference
Source Location
- Repository: Alibaba_MNN
- File:
3rd_party/flatbuffers/src/idl_gen_text.cpp - Lines: 1-310
Signature
namespace flatbuffers {
bool GenerateText(const Parser &parser,
const void *flatbuf,
std::string *text);
bool GenerateTextFile(const Parser &parser,
const std::string &path,
const std::string &file_name);
}
Import
#include "flatbuffers/idl.h"
// Text generation invoked via flatc or API
I/O Contract
| Input | Output |
|---|---|
| Binary FlatBuffer data + parsed schema | JSON text string representing the buffer contents |
| Binary FlatBuffer file + schema | .json output file
|
Usage Examples
#include "flatbuffers/idl.h"
flatbuffers::Parser parser;
parser.Parse(schema_text);
std::string json;
flatbuffers::GenerateText(parser, flatbuf_data, &json);
// json now contains the human-readable representation
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment