Skip to content

Commit

Permalink
Merge pull request #13 from webability-go/late-night
Browse files Browse the repository at this point in the history
patch v0.0.12
  • Loading branch information
metalwolf committed Apr 13, 2020
2 parents 1b75472 + 2709aa4 commit e9fce1d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -20,6 +20,10 @@ TO DO:
Version Changes Control
=======================

v0.0.12 - 2020-04-13
------------------------
- Correction on node: JSON Marshal, wrong ',' calculations

v0.0.11 - 2020-04-13
------------------------
- Added parameters to creation of containers, zones, dataset and elements
Expand Down
14 changes: 9 additions & 5 deletions node.go
Expand Up @@ -278,19 +278,21 @@ func (n *Node) MarshalJSON() ([]byte, error) {
length := len(n.attributes)
candidate := length != 0 || n.ID != "" || n.Type != ""
if candidate {
count := 0
buffer.WriteString(",\"attributes\":{")
if n.ID != "" {
count++
buffer.WriteString("\"id\":\"" + n.ID + "\"")
}
if n.Type != "" {
if n.ID != "" {
if count > 0 {
buffer.WriteString(",")
}
count++
buffer.WriteString("\"type\":\"" + n.Type + "\"")
}
count := 0
for akey, avalue := range n.attributes {
if count > 0 || n.ID != "" || n.Type != "" {
if count > 0 {
buffer.WriteString(",")
}
if avalue == "" {
Expand All @@ -309,7 +311,8 @@ func (n *Node) MarshalJSON() ([]byte, error) {
// children
clength := len(n.children)
if clength > 0 {
buffer.WriteString(",\"children\":[")
buffer.WriteString(",")
buffer.WriteString("\"children\":[")
count := 0
for _, cvalue := range n.children {
if count > 0 {
Expand All @@ -331,7 +334,8 @@ func (n *Node) MarshalJSON() ([]byte, error) {
if err != nil {
return nil, err
}
buffer.WriteString(",\"data\":" + string(jsonValue))
buffer.WriteString(",")
buffer.WriteString("\"data\":" + string(jsonValue))
}

buffer.WriteString("}")
Expand Down
2 changes: 1 addition & 1 deletion wajaf.go
Expand Up @@ -7,7 +7,7 @@
package wajaf

// VERSION is the used version nombre of the XCore library.
const VERSION = "0.0.11"
const VERSION = "0.0.12"

// LOG is the flag to activate logging on the library.
// if LOG is set to TRUE, LOG indicates to the XCore libraries to log a trace of functions called, with most important parameters.
Expand Down
6 changes: 6 additions & 0 deletions wajaf_test.go
Expand Up @@ -63,6 +63,12 @@ func TestWajafLoad(t *testing.T) {
// s, err := json.Marshal(app)

// fmt.Println("JSON = ", string(s), err)
json, err := json.Marshal(app)
if err != nil {
fmt.Println("error json marshal", err)
return
}
fmt.Println("JSON CODE", string(json))

return
}

0 comments on commit e9fce1d

Please sign in to comment.