mobxjs / serializr

Serialize and deserialize complex object graphs to and from JSON and Javascript classes
MIT License
766 stars 52 forks source link

How to serialize Map<string, string> using decorators? #44

Closed lestal closed 7 years ago

lestal commented 7 years ago

I've got a map structure in my class:

export class Market {

@serializable(map(list(primitive()))) service_map: any;
constructor() {}
}

What is the proper way to serialize this dynamic map, because I always get "ERROR Error: [serializr] expected JSON array"

Example of such map:

Object {member: "dev", campaign: "vacation", service: "free"} Keys are always dynamic (I can not define them as schema) and values as well.

lestal commented 7 years ago

I solved it, I had to use @serializable(map(primitive())) instead of @serializable(map(list(primitive())))