Skip to content

Commit dc4fbfb

Browse files
authored
Merge pull request #32 from netplex/pr/21
Pr/21
2 parents d44241c + 8aa02c8 commit dc4fbfb

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

json-smart/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,4 @@
260260
</plugin>
261261
</plugins>
262262
</build>
263-
</project>
263+
</project>

json-smart/src/main/java/net/minidev/json/JSONArray.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ public static void writeJSONString(List<? extends Object> list, Appendable out)
7979
writeJSONString(list, out, JSONValue.COMPRESSION);
8080
}
8181

82+
/**
83+
* Appends the specified element and returns this.
84+
* Handy alternative to add(E e) method.
85+
*
86+
* @param element element to be appended to this array.
87+
* @return this
88+
*/
89+
public JSONArray appendElement(Object element) {
90+
add(element);
91+
return this;
92+
}
93+
8294
public void merge(Object o2) {
8395
JSONObject.merge(this, o2);
8496
}

json-smart/src/main/java/net/minidev/json/JSONObject.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@ else if (!compression.mustProtectKey(key))
9898
JSONValue.writeJSONString(value, out, compression);
9999
}
100100

101+
/**
102+
* Puts value to object and returns this.
103+
* Handy alternative to put(String key, Object value) method.
104+
*
105+
* @param fieldName key with which the specified value is to be associated
106+
* @param fieldValue value to be associated with the specified key
107+
* @return this
108+
*/
109+
public JSONObject appendField(String fieldName, Object fieldValue) {
110+
put(fieldName, fieldValue);
111+
return this;
112+
}
113+
101114
/**
102115
* A Simple Helper object to String
103116
*

0 commit comments

Comments
 (0)