Skip to content

Releases: MCDevKit/jsonte

2.16.0

27 May 19:40

Choose a tag to compare

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

25 Oct 09:07

Choose a tag to compare

Changelog

  • e9ffd3d Fix docs
  • 6a202aa Fix goreleaser config
  • f925ab3 Fix panic error when evaluating an empty expression
  • 2a7348b Fix small issues
  • 7db2517 Implement array templating
  • e213be5 Properly handle incorrect lambdas
  • ca30569 Skip checking for regex patterns of variable names

2.14.0

30 Apr 09:51

Choose a tag to compare

Changelog

  • f1bfff0 Add CLI flags for safe mode and server mode, add server mode and fix getXFile in server mode
  • c879681 Implement basic scripting
  • 3bf865d Implement safe mode
  • 110fb6d Update go and modules

2.13.1

11 Oct 09:52

Choose a tag to compare

Changelog

  • 777e37e Fix comparing objects and add tests for it

2.13.0

24 Sep 19:46

Choose a tag to compare

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

19 Jul 09:29

Choose a tag to compare

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

2.11.3

12 Jul 07:50

Choose a tag to compare

Changelog

  • dcde1aa Fix another place, that didn't handle multibyte characters correctly
  • 50ca425 Fix incorrect documentation for sort function
  • 38b309e Fix yet another place, that didn't handle multibyte characters correctly

2.11.2

26 Jun 06:48

Choose a tag to compare

Changelog

  • 630d372 Fix 2 more places with incorrect handling of multibyte characters

2.11.1

25 Jun 06:59

Choose a tag to compare

Changelog

  • bf64c37 Fix encoding issue when unescaping a string containing multibyte characters

2.11.0

23 Jun 16:29

Choose a tag to compare

Changelog

  • 45517b2 Add toHex, fromHex, hsl, greyscale and arrayToHex functions
  • c5db966 Fix arrayToHex function
  • 214b48a Fix sort function variant, that accepts a predicate
  • 9ea7099 Fix test