blob: 53be5a1bda5702aa1ce7c8ecd2e629e65ec6392f (
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 <a href="mailto:bratseth@yahoo-inc.com">Jon Bratseth</a>
*/
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));
}
}
|