Menu

some suggestion to simplify the json output

floyd
2009-02-01
2013-04-29
  • floyd

    floyd - 2009-02-01

    1. can you omit 'null' value in serialization or make it configable by any way

    2. Besides,i need the key in json-map to be left un-quoted(quotes of the key are unnecessary for me at all) after serialization.can you add this feature??

    the following is the code Snippets from jsonobject apapted by me :).
    ------------------------------------------------------
    private static boolean addQuote = System.getProperty("net.sf.json.toString.addQuote")!=null;
       public String toString() {
          ...
                Object o = keys.next();
                if (addQuote){
                    sb.append( JSONUtils.quote( o.toString() ) );
                }else{
                    sb.append(  o.toString()  );
                }
          ...
      }
    ------------------------------------------------------
    i'm using json-lib 2.2.2

     
    • aalmiray

      aalmiray - 2009-02-01

      Floyd,

      #1 You can skip properties by setting a JsonPropertyFilter on a JsonConfig instance
      jsonConfig.setJsonPropertyFilter(PropertyFilter jsonPropertyFilter)

      #2 can be solved by calling WebUtils.toString(JSON) no need to change JSONObject

      Cheers,
      Andres

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.