# JSLT ### Everyones favorite [XSLT](https://www.w3schools.com/xml/xsl_intro.asp) but for json Rust port for Schibsted's [jslt](https://github.com/schibsted/jslt#jslt) ```rust use jslt::Jslt; use serde_json::json; fn main() -> Result<(), Box> { let jslt: Jslt = r#" { "result" : { for (.menu.popup.menuitem) .value : .onclick } } "# .parse()?; let input = json!({ "menu": { "popup": { "menuitem": [ { "value": "Open", "onclick": "OpenDoc()" }, { "value": "Close", "onclick": "CloseDoc()" } ] } } }); let output = jslt.transform_value(&input)?; assert_eq!( output, json!({ "result" : { "Open" : "OpenDoc()", "Close" : "CloseDoc()" } }) ); Ok(()) } ``` ## Status: POC There is very minial support for selectors, constants and for loops and no garantee this will continue any further in the current phase. Quick support reference: - [x] `.` - [x] `.` - [x] `.[]` - [x] `.[ : ]` - [x] `if () else ` - [x] `let = ` - [x] `$` - [x] `[for () ]` - [x] `{for () : }` - [x] `def (, ...) ` - [x] `// ` - [x] `{ : }` - [x] `{ : , * : . }` - [x] `5 * 7 + 23.2` - [x] `7 < 5` - [x] `7 < 5 and .foo == "yes"` Based on [Quick reference](https://github.com/schibsted/jslt#quick-references) ### Current Goals: - [x] Create context for function registration and scopes for variables - [ ] Enable `#![no_std]` sooner than later for possible nodejs support * \* with `std` cargo flag for regular use.