package zutil.parser.json;

import org.junit.Test;
import zutil.parser.DataNode;

import static org.junit.Assert.*;

public class JSONWriterTest {

    @Test
    public void emptyNodes() {
        assertEquals("{}", JSONWriter.toString(new DataNode(DataNode.DataType.Map)));
        assertEquals("[]", JSONWriter.toString(new DataNode(DataNode.DataType.List)));
    }

    @Test
    public void escapeQuotes() {
        DataNode node = new DataNode(DataNode.DataType.List);
        node.add("aa \"bb\" cc");
        assertEquals("[\"aa \\\"bb\\\" cc\"]", JSONWriter.toString(node));
    }
}