Skip to content
This repository was archived by the owner on May 7, 2022. It is now read-only.

Commit 6fd508c

Browse files
committed
feat: added method to judge whether a JsonObject is empty
1 parent c72b493 commit 6fd508c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

lib/json_object.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ class JsonObject {
2626

2727
void Function(Object newValue) _listen;
2828

29+
static bool isEmpty(JsonObject jsonObject) {
30+
return jsonObject == null ||
31+
jsonObject._map == null &&
32+
jsonObject._list == null &&
33+
jsonObject._normalValue == null;
34+
}
35+
36+
static bool isNotEmpty(JsonObject jsonObject) => !isEmpty(jsonObject);
37+
2938
/// Creates a dynamic(actually a JsonObject) from json string.
3039
dynamic fromString(String jsonStr) {
3140
var decodeResult = json.decode(jsonStr);

0 commit comments

Comments
 (0)