Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kemsky/JsonMapper
Typed JSON parser for ActionScript
https://github.com/kemsky/JsonMapper
adobe-air adobe-flash adobe-flex json-mapper json-serialization
Last synced: 3 months ago
JSON representation
Typed JSON parser for ActionScript
- Host: GitHub
- URL: https://github.com/kemsky/JsonMapper
- Owner: kemsky
- License: mit
- Created: 2014-06-15T15:40:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-06-15T19:13:13.000Z (over 10 years ago)
- Last Synced: 2024-08-04T05:02:48.596Z (6 months ago)
- Topics: adobe-air, adobe-flash, adobe-flex, json-mapper, json-serialization
- Language: ActionScript
- Size: 402 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-actionscript-sorted - JsonMapper - Typed JSON parser for ActionScript (File Formats / JSON)
README
JsonMapper
==========Typed JSON parser for ActionScript
Uses built-in [JSON](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/JSON.html) class if available,
also can fall back to pure ActionScript JSON parser [implementation](https://github.com/mikechambers/as3corelib).Usage
1. Put annotations (`[Serialized(required=true/false)]` and `[ArrayElementType("type")]`):
```ActionScript
public class JsonVO
{
[Serialized(required="true")]
public var id:String = null;
[Serialized]
public var path:String = null;
[Serialized(required="false")]
public var name:String = null;
[Serialized]
public var description:String = null;
[Serialized]
public var value:Number;
[Serialized]
public var date:Date;
[Serialized]
[ArrayElementType("converter.rest.vo.JsonVO")]
public var properties:Array;
[Serialized]
[ArrayElementType("String")]
public var vector:Vector. = Vector.(["test", "test"]);
[Serialized]
[ArrayElementType("Boolean")]
public var booleans:Array = [[true, false], [true, false]];
[Serialized]
[ArrayElementType("converter.rest.vo.JsonVO")]
public var nested:Array = [];
[Serialized]
[ArrayElementType("int")]
public var aCollection:ArrayCollection = new ArrayCollection([1, 2, 3]);
}
```
2. Map entity:```ActionScript
var mapper:JsonMapper = new JsonMapper();
mapper.registerClass(JsonVO);
```
3. Decode JSON:```ActionScript
var result:JsonVO = new JsonDecoder(mapper).decode(message, JsonVO);
```
You can add metadata validation to Intellij Idea using KnownMetaData.dtd file.
Open `Preferences > Schemas and DTDs > Add` KnownMetaData.dtd with URI `urn:Flex:Meta`.