Compile-time JSON syntax checking in Rapture JSON
| Welcome to Scala version 2.10.4 (OpenJDK 64-Bit Server VM, Java 1.6.0_27). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> import rapture.json._ | |
| import rapture.json._ | |
| scala> import jsonBackends.scalaJson._ | |
| import jsonBackends.scalaJson._ | |
| scala> json"{}" | |
| res0: rapture.json.Json = {} | |
| scala> json"""{ "foo"; "bar" }""" | |
| <console>:14: error: Expected ':', but found ';' | |
| json"""{ "foo"; "bar" }""" | |
| ^ | |
| scala> json"""{ "foo": "bar")""" | |
| <console>:14: error: Expected ',' or '}', but found ')' | |
| json"""{ "foo": "bar")""" | |
| ^ | |
| scala> json"""{ "foo": "bar", }""" | |
| <console>:14: error: Expected '"', but found '}' | |
| json"""{ "foo": "bar", }""" | |
| ^ | |
| scala> json"""{ "foo": ${2 + 2} }""" | |
| res5: rapture.json.Json = {"foo":4} | |
| scala> json"""{ "foo": ${2 + 2}, "bar": * }""" | |
| <console>:14: error: Expected new token, but found '*' | |
| json"""{ "foo": ${2 + 2}, "bar": * }""" | |
| ^ | |
| scala> json"""{ ${2 + 2}: "foo", "bar": * }""" | |
| <console>:14: error: Expected '"' or '}', but found interpolated value | |
| json"""{ ${2 + 2}: "foo", "bar": * }""" | |
| ^ |
This comment has been minimized.
This comment has been minimized.
|
Cool! |
This comment has been minimized.
This comment has been minimized.
|
Nice! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
JSON literals will now get parsed at compile time.