001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.json;
016    
017    /**
018     * @author Brian Wing Shun Chan
019     */
020    public class JSONFactoryUtil {
021    
022            public static String convertJSONMLArrayToXML(String jsonml) {
023                    return getJSONFactory().convertJSONMLArrayToXML(jsonml);
024            }
025    
026            public static String convertJSONMLObjectToXML(String jsonml) {
027                    return getJSONFactory().convertJSONMLObjectToXML(jsonml);
028            }
029    
030            public static String convertXMLtoJSONMLArray(String xml) {
031                    return getJSONFactory().convertXMLtoJSONMLArray(xml);
032            }
033    
034            public static String convertXMLtoJSONMLObject(String xml) {
035                    return getJSONFactory().convertXMLtoJSONMLObject(xml);
036            }
037    
038            public static JSONArray createJSONArray() {
039                    return getJSONFactory().createJSONArray();
040            }
041    
042            public static JSONArray createJSONArray(String json) throws JSONException {
043                    return getJSONFactory().createJSONArray(json);
044            }
045    
046            public static <T> JSONDeserializer<T> createJSONDeserializer() {
047                    return getJSONFactory().createJSONDeserializer();
048            }
049    
050            public static JSONObject createJSONObject() {
051                    return getJSONFactory().createJSONObject();
052            }
053    
054            public static JSONObject createJSONObject(String json)
055                    throws JSONException {
056    
057                    return getJSONFactory().createJSONObject(json);
058            }
059    
060            public static JSONSerializer createJSONSerializer() {
061                    return getJSONFactory().createJSONSerializer();
062            }
063    
064            public static Object deserialize(JSONObject jsonObj) {
065                    return getJSONFactory().deserialize(jsonObj);
066            }
067    
068            public static Object deserialize(String json) {
069                    return getJSONFactory().deserialize(json);
070            }
071    
072            public static JSONFactory getJSONFactory() {
073                    return _jsonFactory;
074            }
075    
076            public static String getNullJSON() {
077                    return getJSONFactory().getNullJSON();
078            }
079    
080            public static Object looseDeserialize(String json) {
081                    return getJSONFactory().looseDeserialize(json);
082            }
083    
084            public static <T> T looseDeserialize(String json, Class<T> clazz) {
085                    return getJSONFactory().looseDeserialize(json, clazz);
086            }
087    
088            public static String looseSerialize(Object object) {
089                    return getJSONFactory().looseSerialize(object);
090            }
091    
092            public static String looseSerialize(
093                    Object object, JSONTransformer jsonTransformer, Class<?> clazz) {
094    
095                    return getJSONFactory().looseSerialize(object, jsonTransformer, clazz);
096            }
097    
098            public static String looseSerialize(Object object, String... includes) {
099                    return getJSONFactory().looseSerialize(object, includes);
100            }
101    
102            public static String looseSerializeDeep(Object object) {
103                    return getJSONFactory().looseSerializeDeep(object);
104            }
105    
106            public static String serialize(Object object) {
107                    return getJSONFactory().serialize(object);
108            }
109    
110            public static String serializeException(Exception exception) {
111                    return getJSONFactory().serializeException(exception);
112            }
113    
114            public void setJSONFactory(JSONFactory jsonFactory) {
115                    _jsonFactory = jsonFactory;
116            }
117    
118            private static JSONFactory _jsonFactory;
119    
120    }