This is an automated email from the ASF dual-hosted git repository.
harbs pushed a commit to branch feature/router
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/feature/router by this push:
new 3e403cb Added conversion to and from json
3e403cb is described below
commit 3e403cbe0e6c95a2014cd3e9f57cf50497aec59b
Author: Harbs <[email protected]>
AuthorDate: Sun Feb 2 20:56:32 2020 +0200
Added conversion to and from json
---
.../src/main/royale/jewel/todomvc/models/TodoModel.as | 3 +++
.../todomvc/src/main/royale/jewel/todomvc/vos/TodoVO.as | 13 +++++++++++++
2 files changed, 16 insertions(+)
diff --git
a/examples/jewel/todomvc/src/main/royale/jewel/todomvc/models/TodoModel.as
b/examples/jewel/todomvc/src/main/royale/jewel/todomvc/models/TodoModel.as
index a440eb4..95dc648 100644
--- a/examples/jewel/todomvc/src/main/royale/jewel/todomvc/models/TodoModel.as
+++ b/examples/jewel/todomvc/src/main/royale/jewel/todomvc/models/TodoModel.as
@@ -84,6 +84,9 @@ package jewel.todomvc.models
{
try{
itemArr = JSON.parse(itemStr) as Array;
+ for(var i:int=0;i<itemArr.length;i++){
+ itemArr[i] = TodoVO.fromJSON(itemArr[i]);
+ }
}catch(err:Error){
return [];
}
diff --git a/examples/jewel/todomvc/src/main/royale/jewel/todomvc/vos/TodoVO.as
b/examples/jewel/todomvc/src/main/royale/jewel/todomvc/vos/TodoVO.as
index 1ef8d62..8fb4ee7 100644
--- a/examples/jewel/todomvc/src/main/royale/jewel/todomvc/vos/TodoVO.as
+++ b/examples/jewel/todomvc/src/main/royale/jewel/todomvc/vos/TodoVO.as
@@ -43,5 +43,18 @@ package jewel.todomvc.vos
{
this.label = label;
}
+
+ public function toJSON():Object{
+ return {
+ "label":label,
+ "done":done
+ }
+ }
+ public static function fromJSON(data:Object):TodoVO
+ {
+ var todo:TodoVO = new TodoVO(data["label"]);
+ todo.done = data["done"];
+ return todo;
+ }
}
}