Releases: MCDevKit/jsonte
2.16.0
Changelog
This has been one of the biggest update to jsonte since 2.0.0. It introduces scripting, new functions, new files support and massive optimizations.
New language features
Template strings (backtick syntax)
Expressions can now use backtick-delimited template strings with ${...} interpolation:
`Hello, ${name}!`
`Value is ${items.count()} items`
+= operator
A new AddAssign operator appends/adds to an existing field in-place:
total += item.price
parts += newItem
Block lambdas
Lambdas can now have a statement body instead of a single expression:
x => { return x * 2; }
(a, b) => { if (a > b) { return a; } return b; }
Lambdas as first-class values
A lambda can be stored in a variable and called later:
double = x => x * 2
result = double(5)
New file type: .molang
.molang files are now processed by jsonte. Template expressions (#{...}) are evaluated, # comments are stripped, and the output is minified using Molang-specific rules (collapsing whitespace, shortening query.foo to q.foo, etc.). Molang files are processed right after loading scope and running .jsonte scripts, so be aware of that before you load them in scripts.
New file type: .jsonte
Scope directories are now scanned for .jsonte script files. A .jsonte scope file is evaluated as a script against the current scope; it can add new top-level scope keys via $scope.key = value or mutate existing scope keys like settings.radius = 10;. It is particularly useful for defining complex lambdas
$scope.testLambda = (a, b) => {
return a + b;
};New functions
join() with no separator
Calling array.join() with no arguments joins all elements into a string with no separator between them.
loadText(path)
Loads a file as a raw string, useful for embedding text file contents directly into a template field:
{ "pre_effect_script": "{{loadText('data/jsonte/molang/pre_effect_script.molang')}}" }Optimizations
Template processing has been significantly optimized. Benchmarked on a large real-world project:
- 2.4x faster (57% reduction in processing time)
- 9.5x less memory usage (89% reduction)
- 17x fewer allocations (94% reduction)
New CLI features
--workers N flag
Template files are now processed concurrently. Pass --workers N to set the number of parallel workers; --workers 0 defaults to the number of CPU cores. Previously all processing was single-threaded.
jsonte help command
New help subcommand for built-in function reference:
jsonte help # general usage
jsonte help functions # list all functions
jsonte help <functionName> # docs for a specific function
jsonte help <groupName> # all functions in a group
This is particularly useful for LLM agents
Inline JSON scope
The --scope flag now accepts a raw JSON object string in addition to file/directory paths:
jsonte generate --scope '{"debug":true}' ...
File traversal
Directory walking now follows symlinked subdirectories (with cycle detection to prevent infinite loops).
Full Changelog: 2.15.0...2.16.0
2.15.0
2.14.0
2.13.1
2.13.0
Changelog
- daf1ec1 Add JSON path type and support
- 3e18043 Add script support to grammar
- a2f1157 Add tests for assignment operator and improve slightly grammar for future constructs
- 2309507 Add tests for json path and improve implementation
- 3173f1e Change all types to pointer receivers
- 503d844 Fix comparing null and implement a special scope for variables
- 2c55cf7 Fix new array functions, introduce spread operator and add reserved keywords in data
- 726a074 Implement a way for JsonObjects to hold scope as well
- 23b5365 Implement assignment
- 4b2eb53 Merge branch 'scripting' into pointer-receiver-types
- ed8ae61 Move spread operator to be consistent
2.12.0
Changelog
- 7bbebf5 Add module scopes to the templating scope
- 4f95338 Fix chars and length string functions to account for multibyte characters
- f104c80 Fix unescapeString function to account for multibyte characters
- f15a3af Ignore invalid escape sequences
- 3f0dc97 Improve test
- 57584d0 Reformat grammar
- 53a8598 Switch json parser to handle multibyte characters
- 5b80f71 Update (hopefully) all places, that were handling multibyte characters incorrectly