File tree Expand file tree Collapse file tree 5 files changed +11
-7
lines changed Expand file tree Collapse file tree 5 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ Overview:
3333 static Object parse(Reader reader) throws IOException, ParseException;
3434 static String stringify(Object object); // generate JSON text
3535
36- List<String> list (); // returns list of member names
36+ List<String> listNames (); // returns list of member names
3737 boolean exists(String memberName); // alias of the inherited containsKey()
3838 Object put(String memberName, Object value); // inherited
3939 JSON set(String memberName, Object value); // create or replace member
@@ -45,7 +45,7 @@ Overview:
4545 Boolean getBoolean(String memberName, int... indices) throws ClassCastException;
4646 Object[] getArray(String memberName, int... indices) throws ClassCastException;
4747 Object remove(String memberName); // inherited
48- JSON normalize() throws Exception;
48+ JSON normalize() throws Exception; // not required to generate JSON text
4949 String stringify(String memberName, int... indices); // stringify value or array element
5050 String toString(); // overridden, stringify JSON object
5151
Original file line number Diff line number Diff line change @@ -68,6 +68,11 @@ public String toString() {
6868 return stringify ();
6969 }
7070
71+ public List <String > listNames () {
72+ return new ArrayList <>(this .keySet ());
73+ }
74+
75+ // Deprecated 1.1.0
7176 public List <String > list () {
7277 return new ArrayList <>(this .keySet ());
7378 }
Original file line number Diff line number Diff line change @@ -61,8 +61,8 @@ public static void main(String[] args) throws Exception {
6161 .set ("Byte" , (byte ) 0xFF );
6262 log (json );
6363
64- log ("List members: " + json .list ());
65- for (String memberName : json .list ()) {
64+ log ("List members: " + json .listNames ());
65+ for (String memberName : json .listNames ()) {
6666 if (json .get (memberName ) != null ) {
6767 log ("\" " + memberName + "\" is instance of: "
6868 + json .get (memberName ).getClass ().getSimpleName ());
@@ -74,8 +74,8 @@ public static void main(String[] args) throws Exception {
7474 log ("\n \r Normalized:" );
7575 json = json .normalize ();
7676 log (json );
77- log ("List members: " + json .list ());
78- for (String memberName : json .list ()) {
77+ log ("List members: " + json .listNames ());
78+ for (String memberName : json .listNames ()) {
7979 if (json .get (memberName ) != null ) {
8080 log ("\" " + memberName + "\" is instance of: "
8181 + json .get (memberName ).getClass ().getSimpleName ());
@@ -138,7 +138,6 @@ public static void main(String[] args) throws Exception {
138138 + " }\n "
139139 + " } " ;
140140 json = (JSON ) JSON .parse (example1 );
141- log (json );
142141 log (json .get ("Image" ));
143142 log (json .getJSON ("Image" ).set ("Thumbnail" , 256 )); // replace JSON object with number
144143 log (json .getJSON ("Image" ).remove ("Thumbnail" )); // remove member
You can’t perform that action at this time.
0 commit comments