Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
elgs committed Apr 21, 2016
1 parent 53b50bd commit 81fa9a6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions gojq.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"strconv"
"strings"

Expand All @@ -15,6 +16,20 @@ type JQ struct {
Data interface{}
}

// NewFileQuery - Create a new &JQ from a JSON file.
func NewFileQuery(jsonFile string) (*JQ, error) {
raw, err := ioutil.ReadFile(jsonFile)
if err != nil {
return nil, err
}
var data = new(interface{})
err = json.Unmarshal(raw, data)
if err != nil {
return nil, err
}
return &JQ{*data}, nil
}

// NewStringQuery - Create a new &JQ from a raw JSON string.
func NewStringQuery(jsonString string) (*JQ, error) {
var data = new(interface{})
Expand Down

0 comments on commit 81fa9a6

Please sign in to comment.