示例#1
0
/*
	static
*/
void VJSONGraph::Connect( VJSONGraph** inRetainerGraph, const VJSONValue& inRetainedValue)
{
    if (inRetainedValue.IsObject())
        Connect( inRetainerGraph, inRetainedValue.GetObject()->GetGraph());
    else if (inRetainedValue.IsArray())
        Connect( inRetainerGraph, inRetainedValue.GetArray()->GetGraph());
}
示例#2
0
VError VJSONBinaryWriter::StreamValue(const VJSONValue& inValue, VMemoryBuffer<>& outBuff)
{
	VError err = VE_OK;
	sBYTE btype = (sBYTE)inValue.GetType();
	outBuff.AddData(&btype, 1);
	switch( inValue.GetType())
	{
		case JSON_null:
		case JSON_undefined:
		case JSON_true:
		case JSON_false:
			{
				break;
			}
			
		case JSON_string:
			{
				const VInlineString* s = &(inValue.fString);
				sLONG len = (sLONG)s->GetLength();
				outBuff.AddData(&len, 4);
				if (len > 0)
					outBuff.AddData(s->GetCPointer(), len * 2);
				break;
			}

		case JSON_date:
			{
				outBuff.AddData(&inValue.fTimeStamp, sizeof(sLONG8));
				break;
			}

		case JSON_number:
			{
				outBuff.AddData(&inValue.fNumber, sizeof(Real));
				break;
			}

		case JSON_array:
			{
				err = StreamArray( inValue.GetArray(), outBuff);
				break;
			}

		case JSON_object:
			{
				err = StreamObject( inValue.GetObject(), outBuff);
				break;
			}
		
		default:
			xbox_assert( false);
	}
	
	return err;
}
示例#3
0
VError VJSONWriter::StringifyValue( const VJSONValue& inValue, VString& outString)
{
    VError err = VE_OK;
    switch( inValue.GetType())
    {
    case JSON_undefined:
    {
        outString = VJSONValue::sUndefinedString;
        break;
    }

    case JSON_null:
    {
        outString = VJSONValue::sNullString;
        break;
    }

    case JSON_true:
    {
        outString = VJSONValue::sTrueString;
        break;
    }

    case JSON_false:
    {
        outString = VJSONValue::sFalseString;
        break;
    }

    case JSON_string:
    {
        VString s;
        err = inValue.GetString( s);
        s.GetJSONString( outString, GetOptions());
        break;
    }

    case JSON_number:
    {
        VReal r( inValue.GetNumber());
        err = r.GetJSONString( outString, GetOptions());
        break;
    }

    case JSON_array:
    {
        err = StringifyArray( inValue.GetArray(), outString);
        break;
    }

    case JSON_object:
    {
        err = StringifyObject( inValue.GetObject(), outString);
        break;
    }

    default:
        xbox_assert( false);
    }

    return err;
}
示例#4
0
VError VJSONWriter::StringifyValue( const VJSONValue& inValue, VString& outString)
{
	VError err = VE_OK;
	switch( inValue.GetType())
	{
		case JSON_undefined:
			{
				outString = VJSONValue::sUndefinedString;
				break;
			}

		case JSON_null:
			{
				outString = VJSONValue::sNullString;
				break;
			}

		case JSON_true:
			{
				outString = VJSONValue::sTrueString;
				break;
			}

		case JSON_false:
			{
				outString = VJSONValue::sFalseString;
				break;
			}
			
		case JSON_string:
			{
				VString s;
				err = inValue.GetString( s);
				s.GetJSONString( outString, GetOptions());
				break;
			}

		case JSON_date:
			{
				VTime dd;
				VString s;
				inValue.GetTime(dd);
				dd.GetJSONString(s);
				if ((GetOptions() & JSON_AllowDates) != 0)
				{
					outString = "\"!!" + s + "!!\"";
				}
				else
					outString = "\"" + s + "\"";
				break;
			}

		case JSON_number:
			{
				VReal r( inValue.GetNumber());
				err = r.GetJSONString( outString, GetOptions());
				break;
			}

		case JSON_array:
			{
				err = StringifyArray( inValue.GetArray(), outString);
				break;
			}

		case JSON_object:
			{
				err = StringifyObject( inValue.GetObject(), outString);
				break;
			}
		
		default:
			xbox_assert( false);
	}
	
	return err;
}