001    /**
002     * Copyright (c) 2000-2010 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 JSONArray createJSONArray() {
023                    return getJSONFactory().createJSONArray();
024            }
025    
026            public static JSONArray createJSONArray(String json) throws JSONException {
027                    return getJSONFactory().createJSONArray(json);
028            }
029    
030            public static JSONObject createJSONObject() {
031                    return getJSONFactory().createJSONObject();
032            }
033    
034            public static JSONObject createJSONObject(String json)
035                    throws JSONException {
036    
037                    return getJSONFactory().createJSONObject(json);
038            }
039    
040            public static Object deserialize(JSONObject jsonObj) {
041                    return getJSONFactory().deserialize(jsonObj);
042            }
043    
044            public static Object deserialize(String json) {
045                    return getJSONFactory().deserialize(json);
046            }
047    
048            public static JSONFactory getJSONFactory() {
049                    return _jsonFactory;
050            }
051    
052            public static String serialize(Object obj) {
053                    return getJSONFactory().serialize(obj);
054            }
055    
056            public void setJSONFactory(JSONFactory jsonFactory) {
057                    _jsonFactory = jsonFactory;
058            }
059    
060            private static JSONFactory _jsonFactory;
061    
062    }