Hi Andres,
On Tuesday 19 May 2009 16:28:26 Andres Almiray wrote:
> Hi Tim,
>
> Thank you for checking out Json-lib, we hope it proves to be helpful to
> you. Now answers to your questions:
>
>
> "JSONObject uses a HashMap for its properties
> representation because the order of its properties is not important."
> - this is no longer true, as a matter of fact JSONObject uses a
> LinkedHashMap to preserver insertion order, the FAQ must be updated. Have
> in mind that the JSON semantics still declare a JSONObject to be a Bag, per
> the spec.
Good, I thought so, as I had looked at the code and saw you were now
preserving insertion order.
> " What is the relationship to json.org?"
> - Json-lib was born from the code found at json.org and evolved from there.
Yes, but Mr Crockford is not actually a developer on this project?
I think it is important to spell out clearly whether this is a derived project
or one that is actively developed by the originators of JSON.
[snip - ant usage]
> "Oh, I forgot, the main problem, which prompted me to join the list,
> is that the optional setting on the xom jar caused me to have a runtime
> error reported by a user. "
> - an optional dependency means you don't need to download it in order to
> use the library, however you must download it in order to compile one part
> of the library (xml support).
yes, I know what it means, now, after it caused me pain.
I see the use of optional for the ORO library, but not for XOM you
have askd be to read your POM and determine whether I need to manuall include
the XOM jar.
This is not the Maven way.
I am happy to download enormous numbers of jars that I may or may not need,
I am not happy having to make decisions about it.
I think removing optional on the XOM jar would be good.
> Cheers,
> Andres
cheers and thanks for your library
Tim

Hi Tim,
Thank you for checking out Json-lib, we hope it proves to be helpful to you.
Now answers to your questions:
"JSONObject uses a HashMap for its properties
representation because the order of its properties is not important."
- this is no longer true, as a matter of fact JSONObject uses a LinkedHashMap to preserver insertion order, the FAQ must be updated. Have in mind that the JSON semantics still declare a JSONObject to be a Bag, per the spec.
" What is the relationship to json.org?"
- Json-lib was born from the code found at json.org and evolved from there.
"It looks like you have stopped using Maven to actually build the artefacts,
I am new to the list and would like to know why."
- this is due to the current jdk3/jdk5 setup, given that maven is unable to handle several source paths that may contain "duplicate" class definitions. We tried using maven's ant plugin but it didn't quite work, nor maven's profile option. These days the Ant build does all the work, but still uses the pom file for dependency management
"Oh, I forgot, the main problem, which prompted me to join the list,
is that the optional setting on the xom jar caused me to have a runtime
error reported by a user. "
- an optional dependency means you don't need to download it in order to use the library, however you must download it in order to compile one part of the library (xml support).
Cheers,
Andres
-------------------------------------------
http://jroller.com/aalmirayhttp://www.linkedin.com/in/aalmiray
--
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and those who don't.
To understand recursion, we must first understand recursion.
________________________________
From: Tim Pizey <tim.pizey@...>
To: json-lib-user@...
Sent: Tuesday, May 19, 2009 2:58:08 AM
Subject: [json-lib-user] First impressions
Hi,
I am just starting with json-lib, and thought you might like to see
where I bump into the furniture:
I came to json-lib as a replacement for org.json in the hope of
getting junit testing facilities, which I have got, thank you.
I would be interested in more about FAQ 1, as I cannot see any situation in
which a Bag is the right choice: the population order is of interest and
should be preserved. To do otherwise is to throw information away.
The bald statement "JSONObject uses a HashMap for its properties
representation because the order of its properties is not important."
is a bit strong for me. Whilst I am sure that it is correct I would like to
know what would happen if this assumption were not so central.
I like to round trip in unit tests, the throwing away of information,
ie the deliberate removal of ordering means that I am unable to do this
with ease, am not able to use string comparision for equality and
have had to put in a lot of work. Would it not have been possible to preserve
the ordering?
Would the performance hot have been so bad?
FAQ What is the relationship to json.org?
It looks like you have stopped using Maven to actually build the artefacts,
I am new to the list and would like to know why.
When I checkout and type mvn install I get test failure (Kubuntu/sun
java6/AMD64)
cheers
Tim
[INFO] Surefire report directory: /dist/json-lib/target/surefire-reports
org.apache.maven.surefire.booter.SurefireExecutionException: Unable to
instantiate POJO 'class
net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor'; nested exception is
java.lang.InstantiationException:
net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor; nested exception is
org.apache.maven.surefire.testset.TestSetFailedException: Unable to instantiate
POJO 'class net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor'; nested
exception is java.lang.InstantiationException:
net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor
org.apache.maven.surefire.testset.TestSetFailedException: Unable to instantiate
POJO 'class net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor'; nested
exception is java.lang.InstantiationException:
net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor
java.lang.InstantiationException:
net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
json-lib-user mailing list
json-lib-user@...
https://lists.sourceforge.net/lists/listinfo/json-lib-user

On Tuesday 19 May 2009 10:58:08 Tim Pizey wrote:
> Hi,
>
> I am just starting with json-lib, and thought you might like to see
> where I bump into the furniture:
Oh, I forgot, the main problem, which prompted me to join the list,
is that the optional setting on the xom jar caused me to have a runtime
error reported by a user.
I use Maven so as to have my dependencies managed.
I have never before encountered the optional flag.
I am sure you have good reasons for using it, but thought you might like
to know that it bit me.
cheers
Tim

Hi,
I am just starting with json-lib, and thought you might like to see
where I bump into the furniture:
I came to json-lib as a replacement for org.json in the hope of
getting junit testing facilities, which I have got, thank you.
I would be interested in more about FAQ 1, as I cannot see any situation in
which a Bag is the right choice: the population order is of interest and
should be preserved. To do otherwise is to throw information away.
The bald statement "JSONObject uses a HashMap for its properties
representation because the order of its properties is not important."
is a bit strong for me. Whilst I am sure that it is correct I would like to
know what would happen if this assumption were not so central.
I like to round trip in unit tests, the throwing away of information,
ie the deliberate removal of ordering means that I am unable to do this
with ease, am not able to use string comparision for equality and
have had to put in a lot of work. Would it not have been possible to preserve
the ordering?
Would the performance hot have been so bad?
FAQ What is the relationship to json.org?
It looks like you have stopped using Maven to actually build the artefacts,
I am new to the list and would like to know why.
When I checkout and type mvn install I get test failure (Kubuntu/sun
java6/AMD64)
cheers
Tim
[INFO] Surefire report directory: /dist/json-lib/target/surefire-reports
org.apache.maven.surefire.booter.SurefireExecutionException: Unable to
instantiate POJO 'class
net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor'; nested exception is
java.lang.InstantiationException:
net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor; nested exception is
org.apache.maven.surefire.testset.TestSetFailedException: Unable to instantiate
POJO 'class net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor'; nested
exception is java.lang.InstantiationException:
net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor
org.apache.maven.surefire.testset.TestSetFailedException: Unable to instantiate
POJO 'class net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor'; nested
exception is java.lang.InstantiationException:
net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor
java.lang.InstantiationException:
net.sf.json.TestJSONObject$PrefixerPropertyNameProcessor
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)

Hi Marek,
Looks like your bean class must be declared public, otherwise the bean introspection will fail.
Cheers,
Andres
-------------------------------------------
http://jroller.com/aalmirayhttp://www.linkedin.com/in/aalmiray
--
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and those who don't.
To understand recursion, we must first understand recursion.
________________________________
From: Marek <xxxxmarek@...>
To: json-lib-user@...
Sent: Sunday, May 10, 2009 5:41:46 AM
Subject: [json-lib-user] Fwd: Property 'id' has no getter method in class...
Hallo I have very simple example, but it doesn't go.There is print exception and classes: http://stargate.cnl.tuke.sk/%7Emaly/error

Hi Andres and thanks for reply.
The example demonstrates how to use defaultValueProcessor going java->Json;
I need to do the reverse
I have a JSON string that gets converted to JSONObject that get converted to Java.
I have a call:
MyBean obj = (MyBean) JSONObject.toBean(jsResponse, MyBean.class);
When I tried to use JSONConfig with with defaultValueProcessor, it did not help much since all the types are the strings or list of strings.
I noticed that that toBean() can also take JSonConfig - maybe there is something that can be passed there?
Thanks
________________________________
From: Andres Almiray [mailto:aalmiray@...]
Sent: Friday, May 01, 2009 12:06 PM
To: Leonard Gestrin; json-lib-user@...
Subject: Re: [json-lib-user] Is it possible to force JSONObject.toBean() throw exceptions on cast issues for primitives as oppose to using default values?
Hi Leonard,
Yes, you can register a DefaultValueProcessor to do just that.
http://json-lib.sourceforge.net/advanced.htmlhttp://json-lib.sourceforge.net/xref-test/net/sf/json/TestJSONObject.html#812http://json-lib.sourceforge.net/xref-test/net/sf/json/TestJSONObject.html#833
Cheers,
Andres
-------------------------------------------
http://jroller.com/aalmirayhttp://www.linkedin.com/in/aalmiray
--
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and those who don't.
To understand recursion, we must first understand recursion.
________________________________
From: Leonard Gestrin <lgestrin@...>
To: json-lib-user@...
Sent: Thursday, April 30, 2009 8:15:13 PM
Subject: [json-lib-user] Is it possible to force JSONObject.toBean() throw exceptions on cast issues for primitives as oppose to using default values?
Hello, ( I apologize if this is duplicate message)
I noticed that if I have a bean that has primitive member with setters and getters and I try to instantiate it from JSON string that has invalid int for that member, EZ Morph is using default value 0 instead of throwing exceptions.
I looked at the code of EZMorpth and I could not find an easy way to change that default behavior. I would like to be able to differentiate between invalid value and default value. Is there some easy trick I can use to do so?
Thanks
Leonard

Hi Leonard,
Yes, you can register a DefaultValueProcessor to do just that.
http://json-lib.sourceforge.net/advanced.htmlhttp://json-lib.sourceforge.net/xref-test/net/sf/json/TestJSONObject.html#812http://json-lib.sourceforge.net/xref-test/net/sf/json/TestJSONObject.html#833
Cheers,
Andres
-------------------------------------------
http://jroller.com/aalmirayhttp://www.linkedin.com/in/aalmiray
--
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and those who don't.
To understand recursion, we must first understand recursion.
________________________________
From: Leonard Gestrin <lgestrin@...>
To: json-lib-user@...
Sent: Thursday, April 30, 2009 8:15:13 PM
Subject: [json-lib-user] Is it possible to force JSONObject.toBean() throw exceptions on cast issues for primitives as oppose to using default values?
Hello, ( I apologize if this is duplicate message)
I noticed that if I have a bean that has primitive member with setters and getters and I try to instantiate it from JSON string that has invalid int for that member, EZ Morph is using default value 0 instead of throwing exceptions.
I looked at the code of EZMorpth and I could not find an easy way to change that default behavior. I would like to be able to differentiate between invalid value and default value. Is there some easy trick I can use to do so?
Thanks
Leonard

Hello, ( I apologize if this is duplicate message)
I noticed that if I have a bean that has primitive member with setters and
getters and I try to instantiate it from JSON string that has invalid int
for that member, EZ Morph is using default value 0 instead of throwing
exceptions.
I looked at the code of EZMorpth and I could not find an easy way to change
that default behavior. I would like to be able to differentiate between
invalid value and default value. Is there some easy trick I can use to do
so?
Thanks
Leonard