The Json which came from the server contains some refs like this:
[
{
id:"1",
name:"Mehran",
supervisor:
{
id:"2",
name: "Ayaz",
supervisor: null
}
},
{
id:"3",
name:"Ramin",
supervisor: {$ref="1"}
}
]
How does knockout mapping's fromJS
or fromJson
interpret this?
JSON in your example is invalid . It is unexpected token {$ref="1"}
.
Argument for fromJS
function should be the valid JSON
and argument for function fromJson
should be a string representation of valid JSON value.
Knockout will throw exeption in both cases. You should pass full object instead of reference
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.