/*
 *
 * Copyright (C) 2009 EmbedOne.
 * Contact: EmbedOne Software Information (info@embedone.com)
 *
 * Commercial Usage
 * Licensees holding valid EmbedOne Commercial licenses may use this file
 * in accordance with the EmbedOne Commercial License Agreement provided
 * with the Software or, alternatively, in accordance with the terms
 * contained in a written agreement between you and EmbedOne.
 *
 * GNU General Public License Usage
 * Alternatively, this file may be used under the terms of the GNU
 * General Public License version 3.0 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.  Please review the following information to
 * ensure the GNU General Public License version 3.0 requirements will be
 * met: http://www.gnu.org/copyleft/gpl.html.
 *
 * If you are unsure which license is appropriate for your use, please
 * contact the EmbedOne sales department at sales@embedone.com.
 *
 */

// Main reason for this method to exist is to
// stringify json objects into the strings
// however, it doesnt know how to handle loops
// so use only on simple structures

function mSimpleJSONStringify( vJSON ){
	var vString="";
	var vFirst = true;
	
	if( (typeof(vJSON) == "object") && !(vJSON instanceof Array)&& (vJSON != null)){
		vString = vString + "{";
		for( vMember in vJSON ){
			if( !vFirst ){
				vString = vString + ",";
			}
			vString = vString + '"' + vMember +'":'+mSimpleJSONStringify( vJSON[vMember] ) ;
			vFirst = false;
		}
		vString = vString + "}";
	}else if( typeof(vJSON) == "string" ){
			vString = vString + '"' + vJSON +'"' ;	
	}else if( vJSON instanceof Array ){
		vString = vString + "[";
		for( var vCkl = 0; vCkl<vJSON.length; vCkl++ ){
			if( !vFirst ){
				vString = vString + ",";
			}
			vString = vString + mSimpleJSONStringify( vJSON[vCkl] ) ;
			vFirst = false;
		}
		vString = vString + "]";
	}else if( vJSON == null){
			vString = vString + "null";		
	}else{
			vString = vString + vJSON  ;		
	}
	
	return vString;
}
