60{
61 Json::Value root(Json::arrayValue);
62
63 for (auto &pattern : patterns)
64 {
65 Json::Value p;
66 p["front"] = pattern.front;
67 p["back"] = pattern.back;
68 p["type"] = to_string(pattern.type);
69 root.append(p);
70 }
71
72 Json::StreamWriterBuilder builder;
73 builder["commentStyle"] = "None";
74 builder["indentation"] = " ";
75
76 std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
77 std::ofstream out(filename);
78 if (out.fail())
79 throw std::runtime_error("Cannot open file \"" + filename + "\".\n");
80
81 writer->write(root, &out);
82}