https://fabricmc.net/wiki/documentation:fabric_mod_json
| 168 | |
| 169 | // https://fabricmc.net/wiki/documentation:fabric_mod_json |
| 170 | ModDetails ReadFabricModInfo(QByteArray contents) |
| 171 | { |
| 172 | QJsonParseError jsonError; |
| 173 | QJsonDocument jsonDoc = QJsonDocument::fromJson(contents, &jsonError); |
| 174 | auto object = jsonDoc.object(); |
| 175 | auto schemaVersion = object.contains("schemaVersion") ? object.value("schemaVersion").toInt(0) : 0; |
| 176 | |
| 177 | ModDetails details; |
| 178 | |
| 179 | details.mod_id = object.value("id").toString(); |
| 180 | details.version = object.value("version").toString(); |
| 181 | |
| 182 | details.name = object.contains("name") ? object.value("name").toString() : details.mod_id; |
| 183 | details.description = object.value("description").toString(); |
| 184 | |
| 185 | if (schemaVersion >= 1) { |
| 186 | QJsonArray authors = object.value("authors").toArray(); |
| 187 | for (auto author : authors) { |
| 188 | if (author.isObject()) { |
| 189 | details.authors.append(author.toObject().value("name").toString()); |
| 190 | } else { |
| 191 | details.authors.append(author.toString()); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | if (object.contains("contact")) { |
| 196 | QJsonObject contact = object.value("contact").toObject(); |
| 197 | |
| 198 | if (contact.contains("homepage")) { |
| 199 | details.homeurl = contact.value("homepage").toString(); |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | return details; |
| 204 | } |
| 205 | |
| 206 | // https://github.com/QuiltMC/rfcs/blob/master/specification/0002-quilt.mod.json.md |
| 207 | ModDetails ReadQuiltModInfo(QByteArray contents) |