// Path: binarypig/src/main/java/com/endgame/binarypig/util/JsonUtil.java
// public class JsonUtil {
// 	
// 	final protected TupleFactory tupleFactory = TupleFactory.getInstance();
// 	
// 	/**
// 	 * Note: copied from elephantbird pig JsonLoader
// 	 */
// 	boolean isNestedLoadEnabled = true;
// 	public Object wrap(Object value) {
// 
// 		if (isNestedLoadEnabled && value instanceof JSONObject) {
// 			return walkJson((JSONObject) value);
// 		} else if (isNestedLoadEnabled && value instanceof JSONArray) {
// 
// 			JSONArray a = (JSONArray) value;
// 			DataBag mapValue = new NonSpillableDataBag(a.size());
// 			for (int i = 0; i < a.size(); i++) {
// 				Tuple t = tupleFactory.newTuple(wrap(a.get(i)));
// 				mapValue.add(t);
// 			}
// 			return mapValue;
// 
// 		} else {
// 			return value != null ? value.toString() : null;
// 		}
// 	}
// 	
// 	/**
// 	 * Note: copied from elephantbird pig JsonLoader
// 	 */
// 	public Map<String, Object> walkJson(JSONObject jsonObj) {
// 		Map<String, Object> v = Maps.newHashMap();
// 		for (Object key : jsonObj.keySet()) {
// 			v.put(key.toString(), wrap(jsonObj.get(key)));
// 		}
// 		return v;
// 	}
// }


import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.Text;
import org.apache.pig.data.NonSpillableDataBag;
import org.apache.pig.data.Tuple;
import org.json.simple.parser.JSONParser;
import com.endgame.binarypig.util.JsonUtil;
/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with this
 * work for additional information regarding copyright ownership. The ASF
 * licenses this file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 *
 *  Copyright 2013 Endgame Inc.
 *
 */


package com.endgame.binarypig.loaders;



public class ExecutingJsonLoader extends AbstractExecutingLoader 
{
	JSONParser jsonParser = new JSONParser();
// Path: binarypig/src/main/java/com/endgame/binarypig/util/JsonUtil.java
// public class JsonUtil {
// 	
// 	final protected TupleFactory tupleFactory = TupleFactory.getInstance();
// 	
// 	/**
// 	 * Note: copied from elephantbird pig JsonLoader
// 	 */
// 	boolean isNestedLoadEnabled = true;
// 	public Object wrap(Object value) {
// 
// 		if (isNestedLoadEnabled && value instanceof JSONObject) {
// 			return walkJson((JSONObject) value);
// 		} else if (isNestedLoadEnabled && value instanceof JSONArray) {
// 
// 			JSONArray a = (JSONArray) value;
// 			DataBag mapValue = new NonSpillableDataBag(a.size());
// 			for (int i = 0; i < a.size(); i++) {
// 				Tuple t = tupleFactory.newTuple(wrap(a.get(i)));
// 				mapValue.add(t);
// 			}
// 			return mapValue;
// 
// 		} else {
// 			return value != null ? value.toString() : null;
// 		}
// 	}
// 	
// 	/**
// 	 * Note: copied from elephantbird pig JsonLoader
// 	 */
// 	public Map<String, Object> walkJson(JSONObject jsonObj) {
// 		Map<String, Object> v = Maps.newHashMap();
// 		for (Object key : jsonObj.keySet()) {
// 			v.put(key.toString(), wrap(jsonObj.get(key)));
// 		}
// 		return v;
// 	}
// }


// Path: binarypig/src/main/java/com/endgame/binarypig/loaders/ExecutingJsonLoader.java
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.Text;
import org.apache.pig.data.NonSpillableDataBag;
import org.apache.pig.data.Tuple;
import org.json.simple.parser.JSONParser;
import com.endgame.binarypig.util.JsonUtil;

/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with this
 * work for additional information regarding copyright ownership. The ASF
 * licenses this file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 *
 *  Copyright 2013 Endgame Inc.
 *
 */


package com.endgame.binarypig.loaders;



public class ExecutingJsonLoader extends AbstractExecutingLoader 
{
	JSONParser jsonParser = new JSONParser();
	JsonUtil jsonUtil = new JsonUtil();