Comments (7)
You can provide a ContainerFactory to get a LinkedHashMap during decoding:
http://code.google.com/p/json-simple/wiki/DecodingExamples#Example_4_-_Container
_factory
And then use JSONValue.toJSONString() to encode the object:
http://code.google.com/p/json-simple/wiki/EncodingExamples#Example_1-3_-_Encode_
a_JSON_object_-_Using_Map
Then you will get what you expect.
Original comment by [email protected]
on 2 Sep 2010 at 4:51
- Changed state: WontFix
from json-simple.
Original comment by [email protected]
on 2 Sep 2010 at 4:52
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from json-simple.
Should'nt this be considered a possible fix for the next release?
Original comment by [email protected]
on 2 Sep 2010 at 5:45
from json-simple.
Just to note that LinkedHashMaps are somewhat slower for get and put operations
than regular HashMaps. So some people may be interested in keeping good
performance than maintaining object member order.
Original comment by [email protected]
on 9 Mar 2011 at 1:50
from json-simple.
I attached 2 performance tests for constructing hash-map/linked-hash-map:
1) inserts 1.5M integers into each map, and
2) creates many(1.5M) small(<10 keys) maps.
Here are the results:
Many-keys(1500000) delay: mean(-14,63%), stdev(1,86%)
Many-hashes(1500000) delay: mean(23,40%), stdev(5,18%)
Interestingly enough, linked-hash is actually faster(!) when inserting
many-keys.
I'm suspecting it is due to the improved re-sizing of linked-hash-tables.
But it is ~23% slower when creating a lot smaller hashes.
I expect searching into the hashes to be exactly the same.
TEST-ENV:
java.version=1.6.0_22,
java.runtime.version=1.6.0_22-b04,
java.runtime.name=Java(TM) SE Runtime Environment,
java.vendor.url=http://java.sun.com/,
java.vm.version=17.1-b03, java.vm.vendor=Sun Microsystems Inc.,
java.vm.info=mixed mode,
java.vm.name=Java HotSpot(TM) Server VM,
sun.management.compiler=HotSpot Tiered Compilers,
os.arch=i386,
os.version=2.6.36-ck-r3,
os.name=Linux
Original comment by [email protected]
on 9 Mar 2011 at 5:12
Attachments:
from json-simple.
Issue 40 has been merged into this issue.
Original comment by [email protected]
on 10 Mar 2011 at 10:14
from json-simple.
If you are using the Transformer code to collect the Json Strings as
JSONObject +JSONArrays, would it not be better to have theJ SONObject extend
LinkedHashMap as ooposed HashMap to preserve the order of elements
regds,
Chiths
Original comment by [email protected]
on 11 Mar 2011 at 3:08
from json-simple.
Related Issues (20)
- .Net Implementation
- nullpointer when parsing JSON that starts with Array HOT 1
- Request: New Maven release for Junit dependency scope change HOT 3
- Task :test FAILED org.json.simple.Test > testDecode HOT 1
- No Pretty String output option HOT 2
- Is this dependency was include on the default project that generate from Android Studio?
- getPosition() result from ParseException its diferent that the real character position
- Having error 'cannot be cast to class'.
- Unexpected character () at position 0 HOT 1
- Make new release to address CVE-2020-15250 HOT 8
- Bug: StackOverflow in toString() (infinite recursion)
- When will be next release?
- Integrating json-simple into OSS-Fuzz
- defaulting keys to String and using an efficient HashMap for small data could increase the performance. HOT 2
- Stack overflow error caused by json-simple serialization Map
- Stack overflow error caused by json-simple serialization List
- Nested get
- Include Code coverage to JSON Simple
- Activate github actions for pull requests
- ItemList is vulnerable to out of denial of service (DoS) attack
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 json-simple.