当前位置:网站首页>[golang] go parse XMIND
[golang] go parse XMIND
2022-07-21 07:51:00 【Lion...】
1. The goal is
Use go analysis xmind, Later can be converted to excel, Or generate automatic execution steps, etc
2. xmind Examples
3. Code
package main
import (
"archive/zip"
"encoding/json"
"io/ioutil"
"log"
)
const (
fullFilename = "XX System test cases .xmind"
contentFilename = "content.json"
)
type (
Topic struct {
Id string `json:"id"`
Title string `json:"title"`
Children struct {
Attached []Topic `json:"attached"`
} `json:"children"`
}
Sheet struct {
Id string `json:"id"`
Class string `json:"class"`
Title string `json:"title"`
RootTopic Topic `json:"rootTopic"`
}
)
func main() {
zipFp, zipErr := zip.OpenReader(fullFilename)
if zipErr != nil {
log.Fatalf("Failed to open zip file %s: %s\n", fullFilename, zipErr)
}
sheets := make([]Sheet, 0)
for _, file := range zipFp.File {
if file.FileInfo().Name() != contentFilename {
continue
}
contentFp, openErr := file.Open()
if openErr != nil {
log.Fatalf("Failed to open file %s: %s\n", contentFilename, openErr)
}
contentByte, readErr := ioutil.ReadAll(contentFp)
if readErr != nil {
log.Fatalf("Failed to read file %s: %s\n", contentFilename, readErr)
}
jsonErr := json.Unmarshal(contentByte, &sheets)
if jsonErr != nil {
log.Fatalf("Failed to parse json to Sheet: %s\n", jsonErr)
}
prettyJson, _ := json.MarshalIndent(sheets, "", " ")
log.Println(string(prettyJson))
}
}
Output
[
{
"id": "4bf95f2fd57af298967acae36d",
"class": "sheet",
"title": " canvas 1",
"rootTopic": {
"id": "b9aa22deba98b3b20c7ac8aca2",
"title": "XX System ",
"children": {
"attached": [
{
"id": "b58888b5ceebbf0e68dada0656",
"title": " Login module ",
"children": {
"attached": [
{
"id": "2682d182-9543-49ce-86bd-b7752da1bfd7",
"title": " Login function ",
"children": {
"attached": [
{
"id": "78c6cd8f-077d-4134-ae67-b4ddb7fbadb5",
"title": " Correct user name and password , Login successful ",
"children": {
"attached": [
......
边栏推荐
- 初柒科技致力于设计与开发
- IReport导出PDF字体加粗失效
- 【暑期每日一题】洛谷 P1157 组合的输出
- how to deal with "no such file error or diretory" error for a new programmer in QT creator
- PX4模块设计之十:PX4启动过程
- 【Redis】常见知识点总结
- Data structure of MySQL index
- R语言使用mean函数计算样本(观测)数据中指定变量的相对频数:计算dataframe中指定数据列的值等于指定内容的比例(取值为NJ的内容在数据列中的比例)
- IDR of R language epidisplay package The display function obtains the summary statistical information of Poisson regression Poisson model (initial event density ratio IDR value, adjusted event density
- Hcip notes day 9
猜你喜欢
精品方案|海泰云密码应用服务解决方案 打造安全合规的云上应用
Technical Analysis | Doris connector combined with Flink CDC to achieve accurate access to MySQL database and table exactly once
OSPF综合实验
初识MySQL
Kusionstack open source | exploration and practice of kusion model library and tool chain
OCR/STR生僻字数据训练 | PaddleOCR的Fine-tune常见问题汇总(3)
2022 | Sample Efficiency Matters: A Benchmark for Practical Molecular Optimization
推荐一个 WordPress 付费主题站
开源demo| ARCall 小程序开源示例发布
KusionStack 开源|Kusion 模型库和工具链的探索实践
随机推荐
【Golang】go 解析xmind
Unity学习笔记 之 发射小球碰撞物体的代码记录
精品方案|海泰云密码应用服务解决方案 打造安全合规的云上应用
What is the difference between dall-e2 and imgen? Reddit hot post inventory effect difference
第2讲 Hi3861的WiFi实验-API-3
R language ggplot2 visualization: use the ggsummarytable function of ggpubr package to visualize the box diagram, add descriptive statistics under the box diagram, and set clean_ table_ The theme func
Ocr/str data training | vertical fine tune of paddleocr (2)
The drawing principle and application of Bao Jiao Bao Hui Bezier curve
1260. 二维网格迁移
模块学习(二)——MPU6050
不相交集类 (并查集)
VIM encrypted file "recommended collection"
Google Earth engine - merra-2 m2t1nxaer: aerosol daily data set from 1980 to 2022
R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图、设置add参数在小提琴内部添加均值标准差线、设置error.plot参数实际显示箱体
uva11100
放弃免费Inoreader 自建RSS阅读器—Tiny Tiny RSS和FreshRSS
如何提高LED显示屏清晰度?
Hcip notes day 10
Dall-E2和Imgen有什么区别?Reddit热帖盘点效果差异
【暑期每日一题】洛谷 P6850 NOI