Skip to content

Commit

Permalink
Merge pull request #15 from HarshGrandeur/master
Browse files Browse the repository at this point in the history
added js to parse json and create a js object
  • Loading branch information
iamtrask authored Jul 23, 2018
2 parents ead3dca + 48b1eed commit 15c38e8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/convertJsonToTensor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<html>
<script>
var message='{"torch_type": "torch.FloatTensor", "data": [1.0, 2.0, 3.0, 4.0, 5.0], "id": 1476041248, "owners": [0], "is_pointer": false}';
var myObj = JSON.parse(message);


class FloatTensor{
constructor(torch_type,data,id,owners,is_pointer){
this.torch_type=torch_type;
this.data=data;
this.id=id;
this.owners=owners;
this.is_pointer=is_pointer;
}

get torch_type() {
return this._torch_type;
}

set torch_type(torch_type){
this._torch_type=torch_type;
}

show() {
alert(this.id);
}
}

var floatTensor=new FloatTensor("harsh",[1,2],1,[0],false);
floatTensor.torch_type="test";
console.log(floatTensor.torch_type);
floatTensor.show();


</script>

0 comments on commit 15c38e8

Please sign in to comment.