xiatechs / jsonata-go Goto Github PK
View Code? Open in Web Editor NEWThis project forked from blues/jsonata-go
Open Source Go version of JSONata - with Xiatech
License: MIT License
This project forked from blues/jsonata-go
Open Source Go version of JSONata - with Xiatech
License: MIT License
Hello! Is it possible to get a list of variables to evaluate formula? e.g.:
Formula:
$average([accuracy1, accuracy2])
I'd like to get a list:
[]string{"accuracy1", "accuracy2"}
It appears that the $eval
doesn't work as expected.
Input
{
"inputs" : [
{
"a" : 1,
"b" : "{\"c\":11}"
},
{
"a" : 2,
"b": "{\"c\":22}"
}
]
}
and the corresponding jsonata
$map(inputs,function($v){{
"a": $v.a,
"b": $v.b,
"c": $eval($v.b).c
}})
should produce something like this
[
{
"a": 1,
"b": "{\"c\":11}",
"c": 11
},
{
"a": 2,
"b": "{\"c\":22}",
"c": 22
}
]
instead I am getting,
[
{
"a": 1,
"b": "{\"c\":11}"
},
{
"a": 2,
"b": "{\"c\":22}"
}
]
as you can see, "c" is silently failing
Hello, is it possible to add the $eval function as defined:
https://docs.jsonata.org/string-functions#eval
Thanks.
I'd like to evaluate formula:
$average([accuracy1, accuracy2])
Currently, If I don't set accuracy2
, the library will ignore it and return value of accuracy1
. Is it possible to mark some/all variables as obligatory?
Example:
expr, err := jsonata.Compile("$average([accuracy1, accuracy2])")
if err != nil {
log.Fatal("Invalid expression", err)
return
}
res, err := expr.Eval(map[string]any{"accuracy1": 0.9})
Got result: 0.9, nil
.
Wanted result: 0, errUndfinedVariable("accuracy2")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.