// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/keyvalue/KVSaver.java
// static class KVCategory {
//     private final String name;
//     private final List<KVEntry> entries;
// 
//     KVCategory(String name, List<KVEntry> entries) {
//         this.name = name;
//         this.entries = entries;
//     }
// 
//     String getName() {
//         return name;
//     }
// 
//     List<KVEntry> entries() {
//         return entries;
//     }
// 
//     boolean isEmpty() {
//         return entries.isEmpty();
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         KVCategory that = (KVCategory) o;
// 
//         if (name != null ? !name.equals(that.name) : that.name != null) return false;
//         return entries != null ? entries.equals(that.entries) : that.entries == null;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = name != null ? name.hashCode() : 0;
//         result = 31 * result + (entries != null ? entries.hashCode() : 0);
//         return result;
//     }
// }


import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import com.mindcoders.phial.internal.keyvalue.KVSaver.KVCategory;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
package com.mindcoders.phial.internal.keyvalue;





/**
 * Created by rost on 10/22/17.
 */

class KVJsonSerializer {
    @VisibleForTesting
    static final int INDENT_SPACES = 2;
    @VisibleForTesting
    static final String NAME_KEY = "name";
    @VisibleForTesting
    static final String VALUE_KEY = "value";
    @VisibleForTesting
    static final String ENTRIES_KEY = "entries";

    String serializeToString(List<KVCategory> categories) throws JSONException {
        final JSONArray categoriesJsonArray = createCategoriesArray(categories);
        return categoriesJsonArray.toString(INDENT_SPACES);
    }

    @VisibleForTesting
    @NonNull
// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/keyvalue/KVSaver.java
// static class KVCategory {
//     private final String name;
//     private final List<KVEntry> entries;
// 
//     KVCategory(String name, List<KVEntry> entries) {
//         this.name = name;
//         this.entries = entries;
//     }
// 
//     String getName() {
//         return name;
//     }
// 
//     List<KVEntry> entries() {
//         return entries;
//     }
// 
//     boolean isEmpty() {
//         return entries.isEmpty();
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         KVCategory that = (KVCategory) o;
// 
//         if (name != null ? !name.equals(that.name) : that.name != null) return false;
//         return entries != null ? entries.equals(that.entries) : that.entries == null;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = name != null ? name.hashCode() : 0;
//         result = 31 * result + (entries != null ? entries.hashCode() : 0);
//         return result;
//     }
// }


// Path: phial-overlay/src/main/java/com/mindcoders/phial/internal/keyvalue/KVJsonSerializer.java
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import com.mindcoders.phial.internal.keyvalue.KVSaver.KVCategory;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;

package com.mindcoders.phial.internal.keyvalue;





/**
 * Created by rost on 10/22/17.
 */

class KVJsonSerializer {
    @VisibleForTesting
    static final int INDENT_SPACES = 2;
    @VisibleForTesting
    static final String NAME_KEY = "name";
    @VisibleForTesting
    static final String VALUE_KEY = "value";
    @VisibleForTesting
    static final String ENTRIES_KEY = "entries";

    String serializeToString(List<KVCategory> categories) throws JSONException {
        final JSONArray categoriesJsonArray = createCategoriesArray(categories);
        return categoriesJsonArray.toString(INDENT_SPACES);
    }

    @VisibleForTesting
    @NonNull
    JSONArray createCategoriesArray(List<KVCategory> categories) throws JSONException {