Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: 1.0-pr
    • Labels:
      None

      Description

      It is difficult to use.

      JsonArray & JsonObject should direct support primitive type, include:

      Byte, Short, Integer, Long, BigInteger, BigDecimal, Float, Double
      Boolean, String
      null

      JsonArray & JsonObject should include pirimitive operation, like:
      class JsonObject {
      int getIntValue(String name, int defaultValue);
      Integer getInt(String name);
      long getLongValue(String name, int defaultValue);
      Long getLong(String name);
      ... ...

      JsonArray getJsonArray(String name);
      JsonObject getJsonObject(String name);
      }

      class JsonArray {
      int getIntValue(int index, int defaultValue);
      Integer getInt(int index);
      long getLongValue(int index, int defaultValue);
      Long getLong(int index);
      ... ...

      JsonArray getJsonArray(int index);
      JsonObject getJsonObject(int index);
      }

        Activity

        Hide
        jitu added a comment -

        I have already added few methods in JsonObject and JsonArray for common cases. They are convenience methods(still use JsonValue), see http://java.net/jira/browse/JSON_PROCESSING_SPEC-18

        You are raising bigger question which is to not use JsonString, JsonNumber. Instead, use existing types.
        There are few use cases:

        • For example, if the JSON string data is huge, we cannot map to String. But JsonString could be used (perhaps backed up by a file)
        • Number has two many types. And if a number needs to be represented as String, it would be a problem since string is used for JSON string.
        • Having a common type helps, but if it is too difficult to use, then we should consider again. Other option is to mix and match primitives and JsonValue types. But that would be too messy.

        Let us take the discussion to users mailing list.

        Show
        jitu added a comment - I have already added few methods in JsonObject and JsonArray for common cases. They are convenience methods(still use JsonValue), see http://java.net/jira/browse/JSON_PROCESSING_SPEC-18 You are raising bigger question which is to not use JsonString, JsonNumber. Instead, use existing types. There are few use cases: For example, if the JSON string data is huge, we cannot map to String. But JsonString could be used (perhaps backed up by a file) Number has two many types. And if a number needs to be represented as String, it would be a problem since string is used for JSON string. Having a common type helps, but if it is too difficult to use, then we should consider again. Other option is to mix and match primitives and JsonValue types. But that would be too messy. Let us take the discussion to users mailing list.
        Hide
        jitu added a comment -

        There was quite a bit of discussion on the mailing list and also with JDK architects.

        Closing this one without any fix.

        Show
        jitu added a comment - There was quite a bit of discussion on the mailing list and also with JDK architects. Closing this one without any fix.

          People

          • Assignee:
            Unassigned
            Reporter:
            wenshao
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: