-
Notifications
You must be signed in to change notification settings - Fork 0
/
j2s_test.go
40 lines (32 loc) · 1018 Bytes
/
j2s_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package json2schema
import (
"testing"
"encoding/json"
"fmt"
"hami/ums/base/log"
"io/ioutil"
)
func TestMakeSchema(t *testing.T) {
//var ag = ArrayGroup(VarRoot)
//var ag = Field("asd",FieldTypeText)
/*var ag = ObjectGroup(VarRoot)
var js, _ = json.Marshal(ag)
fmt.Println(string(js))*/
//var ag = Kind(KindField).Type(FieldTypeSelect).Name(VarRoot).Make()
data, e := ioutil.ReadFile("/home/sabloger/code/go/sandbox/src/github.com/hamitrip/json2schema/json_sample/b2x_final.json")
if e != nil {
t.Errorf("File error: %v\n", e)
}
/*schema, e := ioutil.ReadFile("/home/sabloger/code/go/sandbox/src/hami/ums/test/test_recources/schema-2.json")
if e != nil {
t.Errorf("File error: %v\n", e)
}*/
//var schemaMap map[string]interface{}
var dataMap interface{}
json.Unmarshal(data, &dataMap)
//json.Unmarshal(schema, &schemaMap)
var ag = MakeSchema(dataMap)
var js, _ = json.Marshal(ag)
fmt.Println(string(js))
log.Logf(log.WithoutColor,"string(js): type: '%T' value: %v",ag,string(js))
}