Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/blues/jsonata-go

go 1.16
go 1.23
10 changes: 10 additions & 0 deletions v1.5.4/.claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"permissions": {
"allow": [
"Bash(ls)",
"Bash(go:*)",
"Bash(grep:*)"
],
"deny": []
}
}
10 changes: 5 additions & 5 deletions callable.go → v1.5.4/callable.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"regexp"
"strings"

"github.com/blues/jsonata-go/jlib"
"github.com/blues/jsonata-go/jparse"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib"
"github.com/blues/jsonata-go/v1.5.4/jparse"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

type callableName struct {
Expand Down Expand Up @@ -48,7 +48,7 @@ func newGoCallableParam(typ reflect.Type) goCallableParam {
t: typ,
}

isOpt := reflect.PtrTo(typ).Implements(jtypes.TypeOptional)
isOpt := reflect.PointerTo(typ).Implements(jtypes.TypeOptional)
if isOpt {
o := reflect.New(typ).Interface().(jtypes.Optional)
p := newGoCallableParam(o.Type())
Expand Down Expand Up @@ -294,7 +294,7 @@ func (c *goCallable) validateArgTypes(argv []reflect.Value) ([]reflect.Value, er
// This is fine for most types but we need to restore
// pointer type Callables.
if v.Kind() == reflect.Struct &&
reflect.PtrTo(v.Type()).Implements(jtypes.TypeCallable) {
reflect.PointerTo(v.Type()).Implements(jtypes.TypeCallable) {
if v.CanAddr() {
v = v.Addr()
}
Expand Down
4 changes: 2 additions & 2 deletions callable_test.go → v1.5.4/callable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"strings"
"testing"

"github.com/blues/jsonata-go/jparse"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jparse"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

var (
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions env.go → v1.5.4/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"strings"
"unicode/utf8"

"github.com/blues/jsonata-go/jlib"
"github.com/blues/jsonata-go/jparse"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib"
"github.com/blues/jsonata-go/v1.5.4/jparse"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

type environment struct {
Expand Down
2 changes: 1 addition & 1 deletion error.go → v1.5.4/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"regexp"

"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

// ErrUndefined is returned by the evaluation methods when
Expand Down
8 changes: 4 additions & 4 deletions eval.go → v1.5.4/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"reflect"
"sort"

"github.com/blues/jsonata-go/jlib"
"github.com/blues/jsonata-go/jparse"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib"
"github.com/blues/jsonata-go/v1.5.4/jparse"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

var undefined reflect.Value
Expand Down Expand Up @@ -1343,7 +1343,7 @@ func (s sequence) Value() reflect.Value {

var (
typeSequence = reflect.TypeOf((*sequence)(nil)).Elem()
typeSequencePtr = reflect.PtrTo(typeSequence)
typeSequencePtr = reflect.PointerTo(typeSequence)
)

func asSequence(v reflect.Value) (*sequence, bool) {
Expand Down
6 changes: 3 additions & 3 deletions eval_test.go → v1.5.4/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"strings"
"testing"

"github.com/blues/jsonata-go/jlib"
"github.com/blues/jsonata-go/jparse"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib"
"github.com/blues/jsonata-go/v1.5.4/jparse"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

type evalTestCase struct {
Expand Down
2 changes: 1 addition & 1 deletion example_eval_test.go → v1.5.4/example_eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"log"

jsonata "github.com/blues/jsonata-go"
jsonata "github.com/blues/jsonata-go/v1.5.4"
)

const jsonString = `
Expand Down
22 changes: 19 additions & 3 deletions example_exts_test.go → v1.5.4/example_exts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,39 @@ import (
"fmt"
"log"
"strings"
"unicode"

jsonata "github.com/blues/jsonata-go"
jsonata "github.com/blues/jsonata-go/v1.5.4"
)

//
// This example demonstrates how to extend JSONata with
// custom functions.
//

// titleCase returns a copy of the string s with all Unicode letters that begin words
// mapped to their Unicode title case.
func titleCase(s string) string {
// Split the string into words
words := strings.Fields(s)
for i, word := range words {
runes := []rune(word)
if len(runes) > 0 {
runes[0] = unicode.ToTitle(runes[0])
}
words[i] = string(runes)
}
return strings.Join(words, " ")
}

// exts defines a function named "titlecase" which maps to
// the standard library function strings.Title. Any function,
// our custom titleCase function. Any function,
// from the standard library or otherwise, can be used to
// extend JSONata, as long as it returns either one or two
// arguments (the second argument must be an error).
var exts = map[string]jsonata.Extension{
"titlecase": {
Func: strings.Title,
Func: titleCase,
},
}

Expand Down
2 changes: 1 addition & 1 deletion jlib/aggregate.go → v1.5.4/jlib/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"reflect"

"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

// Sum returns the total of an array of numbers. If the array is
Expand Down
2 changes: 1 addition & 1 deletion jlib/array.go → v1.5.4/jlib/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"reflect"
"sort"

"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

// Count (golint)
Expand Down
2 changes: 1 addition & 1 deletion jlib/boolean.go → v1.5.4/jlib/boolean.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package jlib
import (
"reflect"

"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

// Boolean (golint)
Expand Down
4 changes: 2 additions & 2 deletions jlib/date.go → v1.5.4/jlib/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"strconv"
"time"

"github.com/blues/jsonata-go/jlib/jxpath"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib/jxpath"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

// 2006-01-02T15:04:05.000Z07:00
Expand Down
4 changes: 2 additions & 2 deletions jlib/date_test.go → v1.5.4/jlib/date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"testing"
"time"

"github.com/blues/jsonata-go/jlib"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

func TestFromMillis(t *testing.T) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion jlib/hof.go → v1.5.4/jlib/hof.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"reflect"

"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

// Map (golint)
Expand Down
10 changes: 3 additions & 7 deletions jlib/jlib.go → v1.5.4/jlib/jlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ package jlib

import (
"fmt"
"math/rand"
"reflect"
"time"

"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

func init() {
// Seed random numbers for Random() and Shuffle().
rand.Seed(time.Now().UnixNano())
}
// Random numbers for Random() and Shuffle() functions are automatically seeded
// in Go 1.20+ without needing to call rand.Seed

var typeBool = reflect.TypeOf((*bool)(nil)).Elem()
var typeCallable = reflect.TypeOf((*jtypes.Callable)(nil)).Elem()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions jlib/number.go → v1.5.4/jlib/number.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strconv"
"strings"

"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

var reNumber = regexp.MustCompile(`^-?(([0-9]+))(\.[0-9]+)?([Ee][-+]?[0-9]+)?$`)
Expand Down Expand Up @@ -116,7 +116,7 @@ func Random() float64 {
// It does this by converting back and forth to strings to
// avoid floating point rounding errors, e.g.
//
// 4.525 * math.Pow10(2) returns 452.50000000000006
// 4.525 * math.Pow10(2) returns 452.50000000000006
func multByPow10(x float64, n int) float64 {
if n == 0 || math.IsNaN(x) || math.IsInf(x, 0) {
return x
Expand Down
4 changes: 2 additions & 2 deletions jlib/number_test.go → v1.5.4/jlib/number_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"fmt"
"testing"

"github.com/blues/jsonata-go/jlib"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

func TestRound(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion jlib/object.go → v1.5.4/jlib/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"reflect"

"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

// typeInterfaceMap is the reflect.Type for map[string]interface{}.
Expand Down
4 changes: 2 additions & 2 deletions jlib/object_test.go → v1.5.4/jlib/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"strings"
"testing"

"github.com/blues/jsonata-go/jlib"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

type eachTest struct {
Expand Down
10 changes: 5 additions & 5 deletions jlib/string.go → v1.5.4/jlib/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"strings"
"unicode/utf8"

"github.com/blues/jsonata-go/jlib/jxpath"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib/jxpath"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

// String converts a JSONata value to a string. Values that are
Expand Down Expand Up @@ -231,9 +231,9 @@ func Join(values reflect.Value, separator jtypes.OptionalString) (string, error)
// regular expression in the source string. Each object in the
// array has the following fields:
//
// match - the substring matched by the regex
// index - the starting offset of this match
// groups - any captured groups for this match
// match - the substring matched by the regex
// index - the starting offset of this match
// groups - any captured groups for this match
//
// The optional third argument specifies the maximum number
// of matches to return. By default, Match returns all matches.
Expand Down
6 changes: 3 additions & 3 deletions jlib/string_test.go → v1.5.4/jlib/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"testing"
"unicode/utf8"

"github.com/blues/jsonata-go/jlib"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

var typereplaceCallable = reflect.TypeOf((*replaceCallable)(nil)).Elem()
Expand All @@ -28,7 +28,7 @@ func TestMain(m *testing.M) {
os.Exit(1)
}

if !reflect.PtrTo(typeMatchCallable).Implements(typeCallable) {
if !reflect.PointerTo(typeMatchCallable).Implements(typeCallable) {
fmt.Fprintln(os.Stderr, "*matchCallable is not a Callable. Aborting...")
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion jparse/doc.go → v1.5.4/jparse/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// syntax trees. Most clients will not need to work with
// this package directly.
//
// Usage
// # Usage
//
// Call the Parse function, passing a JSONata expression as
// a string. If an error occurs, it will be of type Error.
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion jparse/jparse_test.go → v1.5.4/jparse/jparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"
"unicode/utf8"

"github.com/blues/jsonata-go/jparse"
"github.com/blues/jsonata-go/v1.5.4/jparse"
)

type testCase struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion jsonata-server/bench.go → v1.5.4/jsonata-server/bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"encoding/json"

jsonata "github.com/blues/jsonata-go"
jsonata "github.com/blues/jsonata-go/v1.5.4"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions jsonata-server/exts.go → v1.5.4/jsonata-server/exts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package main

import (
"github.com/blues/jsonata-go/jlib"
"github.com/blues/jsonata-go/jtypes"
"github.com/blues/jsonata-go/v1.5.4/jlib"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

// Default format for dates: e.g. 2006-01-02 15:04 MST
Expand Down
4 changes: 2 additions & 2 deletions jsonata-server/main.go → v1.5.4/jsonata-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
_ "net/http/pprof"
"strings"

jsonata "github.com/blues/jsonata-go"
"github.com/blues/jsonata-go/jtypes"
jsonata "github.com/blues/jsonata-go/v1.5.4"
"github.com/blues/jsonata-go/v1.5.4/jtypes"
)

func init() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading