简体   繁体   中英

Immutablejs: How to deserialise a complex JS object

If I receive data from a server in plain JSON that looks like this:

{
    "f223dc3c-946f-4da3-8e77-e8c1fe4d241b": {
        "name": "Dave",
        "age": 16,
        "jobs": [{
            "description": "Sweep the floor",
            "difficulty": 4
        },{
            "description": "Iron the washing",
            "difficulty": 6
        }]
    },
    "84af889a-8fc9-499b-a6ea-97e7a483130c": {
        ...
    }
}

Do I need to loop through all the jobs and convert them to Map s, then convert each object's jobs into a List , then the entire thing into a Map ?

Or does ImmutableJS do this all recursively for me?

正是为此设计了Immutable.fromJS()

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM