-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
134 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,17 @@ | |
</pre> | ||
</h5> | ||
|
||
## Contents | ||
- [About](#about) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Examples](#examples) | ||
- [Performance](#performance) | ||
- [License](#license) | ||
- [Contact](#contact) | ||
|
||
## About | ||
|
||
## Installation | ||
|
||
```bash | ||
|
@@ -40,7 +51,6 @@ If you'd like to see the code that the transform generates, run with `JSON_DEBUG | |
```js | ||
import { JSON } from "json-as"; | ||
|
||
// @json or @serializable work here | ||
@json | ||
class Vec3 { | ||
x: f32 = 0.0; | ||
|
@@ -76,11 +86,15 @@ const player: Player = { | |
isVerified: true | ||
}; | ||
|
||
const stringified = JSON.stringify<Player>(player); | ||
|
||
const serialized = JSON.stringify<Player>(player); | ||
const parsed = JSON.parse<Player>(stringified); | ||
|
||
console.log("Serialized: " + stringified); | ||
console.log("Parsed: " + parsed); | ||
``` | ||
|
||
## Examples | ||
|
||
Classes can even have inheritance. Here's a nasty example | ||
|
||
```js | ||
|
@@ -124,16 +138,15 @@ You can also add it to your `asconfig.json` | |
|
||
If you use this project in your codebase, consider dropping a [star](https://github.com/JairusSW/as-json). I would really appreciate it! | ||
|
||
## Notes | ||
|
||
If you want a feature, drop an issue (and again, maybe a star). I'll likely add it in less than 7 days. | ||
## 📃 License | ||
|
||
## Contact | ||
This project is distributed under an open source license. You can view the full license using the following link: [License](./LICENSE) | ||
|
||
- [Email](mailto:[email protected]) | ||
- [GitHub](https://github.com/JairusSW) | ||
- [Discord](discord.com/users/600700584038760448) | ||
## 📫 Contact | ||
|
||
## Issues | ||
Please send all issues to [GitHub Issues](https://github.com/JairusSW/as-json/issues) and to converse, please send me an email at [[email protected]](mailto:[email protected]) | ||
|
||
Please submit an issue to https://github.com/JairusSW/as-json/issues if you find anything wrong with this library | ||
- **Email:** Send me inquiries, questions, or requests at [[email protected]](mailto:[email protected]) | ||
- **GitHub:** Visit the official GitHub repository [Here](https://github.com/JairusSW/as-json) | ||
- **Website:** Visit my official website at [jairus.dev](https://jairus.dev/) | ||
- **Discord:** Converse with me on [My Discord](discord.com/users/600700584038760448) or on the [AssemblyScript Discord Server](https://discord.gg/assemblyscript/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,42 @@ | ||
import { bs } from "../modules/as-bs/assembly"; | ||
import { JSON } from "./"; | ||
import { describe, expect } from "../modules/test/assembly"; | ||
@json | ||
class Vec3 { | ||
x: f32 = 0.0; | ||
y: f32 = 0.0; | ||
z: f32 = 0.0; | ||
} | ||
|
||
console.log(JSON.stringify(JSON.parse<string>('"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u000f\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f"'))); | ||
console.log('"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u000f\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f"'); | ||
@json | ||
class Player { | ||
@alias("first name") | ||
firstName: string = ""; | ||
lastName: string = ""; | ||
lastActive: i32[] = []; | ||
// // Drop in a code block, function, or expression that evaluates to a boolean | ||
// // @omitif((self) => self.age < 18) | ||
// // @omitif('this.age <= 0') | ||
// age: i32 = 0; | ||
// // @omitnull() | ||
// pos: Vec3 | null = new Vec3(); | ||
// isVerified: boolean = false; | ||
} | ||
|
||
const player: Player = { | ||
firstName: "Emmet", | ||
lastName: "West", | ||
lastActive: [8, 27, 2022], | ||
// age: 23, | ||
// pos: { | ||
// x: 3.4, | ||
// y: 1.2, | ||
// z: 8.3 | ||
// }, | ||
// isVerified: true | ||
}; | ||
|
||
// bs.proposeSize(1024); | ||
const serialized = JSON.stringify<Player>(player); | ||
console.log("Serialized: " + serialized); | ||
// const parsed = JSON.parse<Player>(serialized); | ||
// console.log("Parsed: " + JSON.stringify(parsed)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters