-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong Immutable.Map serialization / parsing when keys are integers #8
Comments
Hi @zalmoxisus I've created a Pull Request with the fix. |
Is this repository no longer maintained? It would be great if this pull request could be merged and a new version released. This issue is over a month old with a fix ready to go |
Seconded! |
@maurobender thanks again for working on this. It fixes the issue, but breaks how it is displayed. A solution would be to transform it into ES6 Map, serializing like so: - if (Immutable.OrderedMap.isOrderedMap(value)) return mark(value.entrySeq().toArray(), 'ImmutableOrderedMap');
+ if (Immutable.OrderedMap.isOrderedMap(value)) return mark(new Map(value.entrySeq().toArray()), 'ImmutableOrderedMap');
- if (Immutable.Map.isMap(value)) return mark(value.entrySeq().toArray(), 'ImmutableMap');
+ if (Immutable.Map.isMap(value)) return mark(new Map(value.entrySeq().toArray()), 'ImmutableMap'); and parsing: - case 'ImmutableMap': return Immutable.Map(data);
+ case 'ImmutableMap': return Immutable.Map(Array.from(data));
- case 'ImmutableOrderedMap': return Immutable.OrderedMap(data);
+ case 'ImmutableOrderedMap': return Immutable.OrderedMap(Array.from(data)); Not sure about OrderedMap. However, there's an issue with reviver on |
Hi @zalmoxisus! Sorry for my late response, I've just saw the notification about this. I've gone through the issue you mentioned but that is a matter only of how the data is displayed when the |
@maurobender we are not including
We should check if it will work well with When Map is not present in the browser we could fall back to the implementation with Array. That's not the case of the extension, but for others which are relying on this library. If you'll have time to work on a modified PR, if not I'll come back to it after modifying |
Issue
When the keys of an
Immutable.Map
object are integers and the map is serialized they are converted to strings and then when the serialization is parsed the map is created with string keys instead of numeric ones.Test
To reproduce the issue you can use the next script:
The result of that script is:
As you can see the parsed Map has string keys instead of the original numeric ones.
Posible fix
Serialize the Map as an array of tuples instead of a JS object.
Change the next line in
immutable/serialize.js
:to
Immutable < 4
Immutable 4
The text was updated successfully, but these errors were encountered: