change pluginmanager json to json5

This commit is contained in:
Florian Sundermann
2016-09-27 13:28:32 +02:00
parent 55c790f069
commit 23ef69b935
2 changed files with 8 additions and 7 deletions

View File

@@ -3,7 +3,6 @@ package main
import ( import (
"archive/zip" "archive/zip"
"bytes" "bytes"
"encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@@ -16,6 +15,7 @@ import (
"sync" "sync"
"github.com/blang/semver" "github.com/blang/semver"
"github.com/yosuke-furukawa/json5/encoding/json5"
"github.com/yuin/gopher-lua" "github.com/yuin/gopher-lua"
) )
@@ -114,7 +114,7 @@ func (pc PluginChannel) Fetch() PluginPackages {
return PluginPackages{} return PluginPackages{}
} }
defer resp.Body.Close() defer resp.Body.Close()
decoder := json.NewDecoder(resp.Body) decoder := json5.NewDecoder(resp.Body)
var repositories []PluginRepository var repositories []PluginRepository
if err := decoder.Decode(&repositories); err != nil { if err := decoder.Decode(&repositories); err != nil {
@@ -134,7 +134,7 @@ func (pr PluginRepository) Fetch() PluginPackages {
return PluginPackages{} return PluginPackages{}
} }
defer resp.Body.Close() defer resp.Body.Close()
decoder := json.NewDecoder(resp.Body) decoder := json5.NewDecoder(resp.Body)
var plugins PluginPackages var plugins PluginPackages
if err := decoder.Decode(&plugins); err != nil { if err := decoder.Decode(&plugins); err != nil {
@@ -152,7 +152,7 @@ func (pv *PluginVersion) UnmarshalJSON(data []byte) error {
Require map[string]string Require map[string]string
} }
if err := json.Unmarshal(data, &values); err != nil { if err := json5.Unmarshal(data, &values); err != nil {
return err return err
} }
pv.Version = values.Version pv.Version = values.Version
@@ -176,7 +176,7 @@ func (pp *PluginPackage) UnmarshalJSON(data []byte) error {
Tags []string Tags []string
Versions PluginVersions Versions PluginVersions
} }
if err := json.Unmarshal(data, &values); err != nil { if err := json5.Unmarshal(data, &values); err != nil {
return err return err
} }
pp.Name = values.Name pp.Name = values.Name

View File

@@ -1,9 +1,10 @@
package main package main
import ( import (
"encoding/json"
"github.com/blang/semver" "github.com/blang/semver"
"testing" "testing"
"github.com/yosuke-furukawa/json5/encoding/json5"
) )
func TestDependencyResolving(t *testing.T) { func TestDependencyResolving(t *testing.T) {
@@ -20,7 +21,7 @@ func TestDependencyResolving(t *testing.T) {
}] }]
` `
var all PluginPackages var all PluginPackages
err := json.Unmarshal([]byte(js), &all) err := json5.Unmarshal([]byte(js), &all)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }