# JSONDB **Repository Path**: sulliy/JSONDB ## Basic Information - **Project Name**: JSONDB - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2015-09-17 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #JSONDB ### 介绍 一个简单的JSON本地缓存。支持键值对存储和数组存储。 ### 示例 #### 键值对 ``` JSONDB jsondb = new JSONDB.Builder().folder("jsondb").connect(); Editor editor = jsondb.edit(); editor.put("me", new Person("Steven", "China")); editor.put("myself", JSON.toJSONString(new Person("Jobs", "China"))); editor.commit(); System.out.println(jsondb.get("me")); System.out.println(jsondb.get("myself")); ``` 输出 {"address":"China","name":"Steven"} {"address":"China","name":"Jobs"} #### 数组 ``` JSONDB jsondb = new JSONDB.Builder().folder("jsondb").mode(JSONDB.ARRAY_MODE).connect(); Editor editor = jsondb.edit(); editor.put("person", new Person("Steven", "China")); editor.put("person", JSON.toJSONString(new Person("Steven", "China"))); editor.put("string", "array mode associated with key"); editor.put("string", "array mode allow empty key"); editor.put("", "null string cannot be a key"); editor.put(null, "empty key is allowed"); editor.put("no key is allowed"); editor.commit(); System.out.println(jsondb.get("person")); System.out.println(jsondb.get("string")); System.out.println(jsondb.get()); System.out.println(jsondb.getAll()); ``` 输出 JSONDB jsondb = new JSONDB.Builder().folder("jsondb").mode(JSONDB.ARRAY_MODE).connect(); Editor editor = jsondb.edit(); editor.put("person", new Person("Steven", "China")); editor.put("person", JSON.toJSONString(new Person("Steven", "China"))); editor.put("string", "array mode associated with key"); editor.put("string", "array mode allow empty key"); editor.put("", "null string cannot be a key"); editor.put(null, "empty key is allowed"); editor.put("no key is allowed"); editor.commit(); System.out.println(jsondb.get("person")); System.out.println(jsondb.get("string")); System.out.println(jsondb.get()); System.out.println(jsondb.getAll());