未验证 提交 a7ccd7f3 编写于 作者: P Phodal HUANG

docs: add format for json

上级 36e4b483
...@@ -50,3 +50,4 @@ language/g4/*.tokens ...@@ -50,3 +50,4 @@ language/g4/*.tokens
language/g4/*.go language/g4/*.go
language/g4/*.interp language/g4/*.interp
coca coca
deps.json
...@@ -2,11 +2,10 @@ package cmd ...@@ -2,11 +2,10 @@ package cmd
import ( import (
"encoding/json" "encoding/json"
"fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
. "../adapter/call" . "../adapter/call"
. "../adapter/identifier" . "../utils"
) )
var collCmd *cobra.Command = &cobra.Command{ var collCmd *cobra.Command = &cobra.Command{
...@@ -20,14 +19,9 @@ var collCmd *cobra.Command = &cobra.Command{ ...@@ -20,14 +19,9 @@ var collCmd *cobra.Command = &cobra.Command{
callApp := new(JavaCallApp) callApp := new(JavaCallApp)
callNodes := callApp.AnalysisPath(importPath) callNodes := callApp.AnalysisPath(importPath)
cModel, _ := json.Marshal(callNodes) cModel, _ := json.MarshalIndent(callNodes, "", "\t")
identifierApp := new(JavaIdentifierApp) WriteToFile("deps.json", string(cModel))
identNodes := identifierApp.AnalysisPath(importPath)
iNodes, _ := json.Marshal(identNodes)
fmt.Println(string(cModel))
fmt.Println(string(iNodes))
} }
}, },
} }
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"os" "os"
) )
func WriteFile(fileName string, payload string) { func WriteToFile(fileName string, payload string) {
_ = ioutil.WriteFile(fileName, []byte(payload), 0644) _ = ioutil.WriteFile(fileName, []byte(payload), 0644)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册