https://github.com/crdsonnet/astsonnet
Jsonnet library to generate jsonnet code.
https://github.com/crdsonnet/astsonnet
abstract-syntax-tree jsonnet jsonnet-lib
Last synced: 3 months ago
JSON representation
Jsonnet library to generate jsonnet code.
- Host: GitHub
- URL: https://github.com/crdsonnet/astsonnet
- Owner: crdsonnet
- License: apache-2.0
- Created: 2024-03-14T10:50:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-14T22:55:55.000Z (8 months ago)
- Last Synced: 2025-02-14T23:27:23.896Z (8 months ago)
- Topics: abstract-syntax-tree, jsonnet, jsonnet-lib
- Language: Jsonnet
- Homepage:
- Size: 38.1 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ASTsonnet
This is a Jsonnet library to generate jsonnet code. This library implements functions to create the Jsonnet expressions as represented in the Abstract Syntax. This allows us to generate valid Jsonnet programmatically. This library is partially generated by itself from a JSON schema representing the Jsonnet AST.
## Install
```
jb install github.com/crdsonnet/astsonnet
```## Usage
```jsonnet filename="example.jsonnet"
local a = import 'github.com/crdsonnet/astsonnet/main.libsonnet';a.object.new([
a.field.new(
a.id.new('hello'),
a.string.new('world'),
),
]).toString()
```Execute it like so:
```
$ jsonnet -S example.jsonnet | jsonnetfmt -{ hello: 'world' }
```Or execute the resulting jsonnet directly:
```
$ jsonnet -S example.jsonnet | jsonnet -{
"hello": "world"
}
```