Comments (14)
One feature of JSON.simple is to be compatible with JDK1.2 and later (both
source
level and binary level, so it supports almost all of JDKs if not all), thus
JSON.simple doesn't use generic feature from JDK1.5 directly, but it does
support all
of Map and List implementations with
JSONValue.toJSONString()/JSONValue.writeJSONString().
As a result, if an application/library can not use JSON.simple, it may be a
build or
configuration issue of that application/library.
Thanks.
Original comment by [email protected]
on 16 Dec 2009 at 8:41
from json-simple.
I followed the link you provided, maybe you can type something like to make it
work:
scala> o.put("a",new Integer(1))
Original comment by [email protected]
on 16 Dec 2009 at 1:22
from json-simple.
Unfortunately no:
scala> obj.put("a",new Integer(1))
<console>:8: error: overloaded method value put with alternatives (K,V)V <and>
((K
with K,_20)_20) forSome { type _20 >: V with V } cannot be applied to
(java.lang.String,java.lang.Integer)
obj.put("a",new Integer(1))
Original comment by [email protected]
on 16 Dec 2009 at 1:32
from json-simple.
The following should work:
scala> val o = new java.util.HashMap[String, Int]()
o: java.util.HashMap[String,Int] = {}
scala> o.put("a",1)
res5: Int = 0
scala> org.json.simple.JSONValue.toJSONString(o)
res6: java.lang.String = {"a":1}
Original comment by [email protected]
on 16 Dec 2009 at 3:51
from json-simple.
Thanks a lot for the tip !
Original comment by [email protected]
on 16 Dec 2009 at 5:47
from json-simple.
Is there any merit to releasing version 2.0 of this library to support language
improvements like generics and strongly typed collections?
Since JDK 1.4 is now reaching end of life, these types of updates would be
really
useful for EE applications built on Java EE 5 where Javascript and Java are
responsible for data exchange.
Original comment by [email protected]
on 5 Mar 2010 at 6:14
from json-simple.
Thank you Owen for your suggestion, I'll re-consider supporting of JDK2. The
initial
intention is to make it compatible with ALL version of JDK as well as J2ME.
Original comment by [email protected]
on 8 Mar 2010 at 5:52
from json-simple.
Original comment by [email protected]
on 29 Nov 2011 at 3:26
- Changed state: Accepted
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from json-simple.
My two cents in favour of migrating to generics: compiling a java project
(which uses json-simple) with javac's -Xlint option results into dozens of
"[unchecked]" warnings. Thanks.
Original comment by [email protected]
on 4 Dec 2012 at 3:09
from json-simple.
Until the library is updated to support generics this could be a case where
@SuppressWarnings("unchecked") makes sense.
Original comment by [email protected]
on 2 May 2013 at 6:48
from json-simple.
Another vote to leave ancient history behind and use generics.
Original comment by [email protected]
on 1 Jul 2013 at 10:52
from json-simple.
Please, stop supporting old version of Java and start supporting generics!
Original comment by [email protected]
on 17 Oct 2013 at 2:32
from json-simple.
One more vote for supporting generics; trying to iterate over the object in an
idiomatic way like so:
for (Map.Entry entry : jsonObject.entrySet()) { /* ... */ }
will lead to compile errors, because the compiler is seeing a Set of Objects
instead of a set to Map.Entry instances.
Looking at
http://zeroturnaround.com/rebellabs/java-tools-and-technologies-landscape-for-20
14/ slide 6: only 2% are still on Java 5, Java4 is not even mentioned anymore.
Original comment by [email protected]
on 6 Jun 2014 at 10:22
from json-simple.
I have a best solution. Instead of this lib, use Gson.
Gson has generics and you need not try to catch an exception on every single
interface method invocation.
Original comment by [email protected]
on 6 Jun 2014 at 1:13
from json-simple.
Related Issues (20)
- linkedHashMap does not preserve order once data has reached client
- Please provide a source archive for release 1.1.1
- MAVEN, json-simple 1.1.1 depends on Junit HOT 4
- bug in get(), ContainerFactory HOT 1
- JSONObject produces warning in code HOT 6
- Long cast error, even if String used HOT 2
- Patch for /trunk/src/main/java/org/json/simple/parser/ContainerFactory.java HOT 2
- nothing is being converted to a JSONObject in my java class, throwing an exception HOT 1
- Building 1.1.1 with java-1.8.0 tests fail - hash not matching? HOT 2
- Functions are missing from json_simple.jar (1.1)
- should not always use toString() as fallback in JSONValue.writeJSONString() HOT 2
- escaped backslash results in new line character if followed by 'n' or 'r' HOT 1
- JSONParser.parse() throws a parse exception on trailing and leading whitespace of a JSON String. HOT 1
- Make junit's scope to test HOT 3
- Build JSONArray from a Collection HOT 1
- StringBuilder and StringBuffer values are unquoted HOT 1
- I need to modify JSON object value at run time.
- Move project to Github HOT 2
- Migrating to GitHub? HOT 1
- MVN Repo and direct download from https://code.google.com/p/json-simple/ are different jars for the same version 1.1.1
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.