1 package net.minidev.json.writer;
2
3 /*
4 * Copyright 2011-2014 JSON-SMART authors
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 import net.minidev.json.JSONArray;
19 import net.minidev.json.JSONAwareEx;
20 import net.minidev.json.JSONObject;
21 /**
22 * Simple Reader Class for generic Map
23 *
24 * @author uriel
25 *
26 * @param <T>
27 */
28 public class DefaultMapper<T> extends JsonReaderI<T> {
29 protected DefaultMapper(JsonReader base) {
30 super(base);
31 }
32
33 @Override
34 public JsonReaderI<JSONAwareEx> startObject(String key) {
35 return base.DEFAULT;
36 }
37
38 @Override
39 public JsonReaderI<JSONAwareEx> startArray(String key) {
40 return base.DEFAULT;
41 }
42
43 @Override
44 public Object createObject() {
45 return new JSONObject();
46 }
47
48 @Override
49 public Object createArray() {
50 return new JSONArray();
51 }
52
53 @Override
54 public void setValue(Object current, String key, Object value) {
55 ((JSONObject) current).put(key, value);
56 }
57
58 @Override
59 public void addValue(Object current, Object value) {
60 ((JSONArray) current).add(value);
61 }
62
63 }
64