summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/test/java/com/yahoo/text/JSONTest.java
blob: 2e7e1da65f0de4d2fef3089cad89b08f897e3d58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.text;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author bratseth
 */
public class JSONTest {

    @Test
    public void testMapToString() {
        Map<String,Object> map = new LinkedHashMap<>();
        map.put("a \"key\"", 3);
        map.put("key2", "value");
        map.put("key3", 3.3);

        assertEquals("{\"a \\\"key\\\"\":3,\"key2\":\"value\",\"key3\":3.3}", JSON.encode(map));
    }

}