Comments (10)
Thanks, that's an interesting observation. The minimum property should be that spray-json should make sure that a round-trip from an ordered collection to json and back should lead to the same result. That should be valid at least.
But I see how you would expect that the entries are also sorted on the json side of things.
The root cause is that
toSeq
directly maps over the given input iterable which moves from TreeSet to Set, because mapping a TreeSet without an ordering isn't possible.
Yep, indeed. I filed scala/bug#11987 but don't expect it can be fixed.
from spray-json.
Using JsArray(iterable.iterator.map(_.toJson).toVector)
would fix it.
from spray-json.
@jrudolph That's more or less what we're using now.
from spray-json.
I think in this context it's also worth pointing out that spray-json should preserve the ordering in the source domain, that is, before converting elements of the collection to JSON, because the ordering of JSON values might be quite different from the ordering of the collection (think off, e.g. a TreeSet with an inverse ordering).
from spray-json.
I think in this context it's also worth pointing out that spray-json should preserve the ordering in the source domain, that is, before converting elements of the collection to JSON, because the ordering of JSON values might be quite different from the ordering of the collection (think off, e.g. a TreeSet with an inverse ordering).
Not sure what you mean. What would be the alternative?
from spray-json.
@jrudolph Well, when serializing a TreeSet
you shouldn't order by the JSON value of its elements, but by the elements itself :)
from spray-json.
@jrudolph I'd just like to check what's the way forward here⦠do you expect me to open a pull request to fix this issue?
from spray-json.
Yes, please. In that case, I'd say adding .iterator
would probably be safest.
from spray-json.
@jrudolph Will do.
from spray-json.
from spray-json.
Related Issues (20)
- Publish for Scala 2.13.0 HOT 3
- Provide implicits automatically without extra imports HOT 1
- Provide jsonFormatN method overloads HOT 4
- JsonParserSpecJvm is failing HOT 3
- Documentation review and migration guide for 1.5.0 release
- How to debug "Cannot find JsonWriter or JsonFormatter type class" errors
- Not able to parse the Json file with its relation_tree and split into multiple Json file for each child without any hard coding of Node/Tag (As structure of Json is not always same also very lengthy json). Input and Output is pasted below :
- Publish 1.3.6 release (including Scala.js) HOT 1
- Scaladoc
- Is JsonParser thread safe?
- Default JsonWriter for collections
- recursive Json Does not seem to work as documented HOT 3
- What are your plans for spray-json regarding Scala 3? HOT 4
- Generated jsonFormatN has unexpectedly large sizeHint HOT 1
- Cross-compile for scala 3? HOT 1
- Introduce an optional Scala 3 macro module, with full pickling support.
- Is this project still maintained? HOT 2
- No implicit arguments of type: JsonReader[Double] HOT 1
- Cannot parse as Long from String format field
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spray-json.