/jay

🐴 immutable json expressions, structural equality and lenses in pony

Primary LanguagePony

jay

🚂🚋🚋🚋🚋🚋
immutable json expressions, structural equality and lenses in pony

Objects

let data = JObj
	+ ("key", I64(1))
	+ ("value", JObj
		+ ("name", "jay")
		+ ("version", "1.0.0")
		+ ("release", true)
		+ ("null", None)
		+ ("dependencies", JArr + "json") 
	  )
{
	"key": 1,
	"value": {
		"name": "jay",
		"version": "1.0.0",
		"release": true,
		"null": null,
		"dependencies": ["json"]
	}
}

Arrays

let array = JArr
	+ "string"
	+ I64(123)
	+ F64(22.7)
	+ true
	+ None
	+ (JObj + ("test", "value"))
["string", 123, 22.7, true, null, {"test": "value"}]

Lenses

let lens = JLens("value")("version") / JLens(USize(2))
assert_eq(lens.json(data), "1.0.0")
assert_eq(lens.json(array), F64(22.7))