コード例 #1
0
JSONTEST_FIXTURE( ValueTest, compareObject )
{
    // object compare size then content
    Json::Value emptyObject(Json::objectValue);
    Json::Value l1aObject;
    l1aObject["key1"] = 0;
    Json::Value l1bObject;
    l1aObject["key1"] = 10;
    Json::Value l2aObject;
    l2aObject["key1"] = 0;
    l2aObject["key2"] = 0;
    JSONTEST_ASSERT_PRED( checkIsLess( emptyObject, l1aObject ) );
    JSONTEST_ASSERT_PRED( checkIsLess( emptyObject, l2aObject ) );
    JSONTEST_ASSERT_PRED( checkIsLess( l1aObject, l2aObject ) );
    JSONTEST_ASSERT_PRED( checkIsEqual( emptyObject, Json::Value( emptyObject ) ) );
    JSONTEST_ASSERT_PRED( checkIsEqual( l1aObject, Json::Value( l1aObject ) ) );
    JSONTEST_ASSERT_PRED( checkIsEqual( l2aObject, Json::Value( l2aObject ) ) );
}
コード例 #2
0
XBOX::VJSValue VJSStructuredClone::_NodeToValue (XBOX::VJSContext inContext, SNode *inNode, std::map<SNode *, JS4D::ValueRef> *ioAlreadyCreated, std::list<SEntry> *ioToDoList)
{
	xbox_assert(ioAlreadyCreated != NULL && ioToDoList != NULL);

	XBOX::VJSValue	value(inContext);

	switch (inNode->fType) {

		case eNODE_UNDEFINED:
	
			value.SetUndefined();
			break;

		case eNODE_NULL:

			value.SetNull();
			break;

		case eNODE_BOOLEAN:
				
			value.SetBool(inNode->fValue.fBoolean);
			break;

		case eNODE_NUMBER:

			value.SetNumber<Real>(inNode->fValue.fNumber);
			break;

		case eNODE_STRING:

			value.SetString(*inNode->fValue.fString);
			break;

		case eNODE_BOOLEAN_OBJECT: 

			value.SetBool(inNode->fValue.fBoolean);
			value = _ConstructObject(inContext, "Boolean", value);
			break;

		case eNODE_NUMBER_OBJECT:

			value.SetNumber(inNode->fValue.fNumber);
			value = _ConstructObject(inContext, "Number", value);
			break;

		case eNODE_STRING_OBJECT:
		case eNODE_REG_EXP_OBJECT: 

			value.SetString(*inNode->fValue.fString);
			value = _ConstructObject(inContext, inNode->fType == eNODE_STRING_OBJECT ? "String" : "RegExp", value);
			break;

		case eNODE_DATE_OBJECT: 

			value.SetNumber(inNode->fValue.fNumber);
			value = _ConstructObject(inContext, "Date", value);
			break;
			
		case eNODE_SERIALIZABLE:
			
			value.SetString(*inNode->fValue.fSerializationData.fJSON);
			value = _ConstructObject(inContext, *inNode->fValue.fSerializationData.fConstructorName, value);
			break;

		case eNODE_OBJECT: {

			XBOX::VJSObject	emptyObject(inContext);
			SEntry			entry;

			emptyObject.MakeEmpty();
			value.SetValueRef((JS4D::ValueRef) emptyObject.GetObjectRef());

			xbox_assert(ioAlreadyCreated->find(inNode->fValue.fReference) == ioAlreadyCreated->end());

			(*ioAlreadyCreated)[inNode] = value.GetValueRef();

			entry.fValueRef = value.GetValueRef();
			entry.fNode = inNode;
			ioToDoList->push_back(entry);

			break;

		}

		case eNODE_ARRAY: {

			XBOX::VJSArray	emptyArray(inContext);
			SEntry			entry;

			value.SetValueRef((JS4D::ValueRef) emptyArray.GetObjectRef());

			xbox_assert(ioAlreadyCreated->find(inNode->fValue.fReference) == ioAlreadyCreated->end());

			(*ioAlreadyCreated)[inNode] = value.GetValueRef();

			entry.fValueRef = value.GetValueRef();
			entry.fNode = inNode;
			ioToDoList->push_back(entry);
			
			break;

		}

		case eNODE_REFERENCE: {

			std::map<SNode *, JS4D::ValueRef>::iterator it;

			it = ioAlreadyCreated->find(inNode->fValue.fReference);
			xbox_assert(it != ioAlreadyCreated->end());

			value.SetValueRef(it->second);

			break;

		}

		default:

			xbox_assert(false);
			value.SetNull();
			break;
		
	}
	
	return value;
}
コード例 #3
0
ファイル: picojson_adapter.hpp プロジェクト: btolfa/valijson
 /// Construct a wrapper for the empty object singleton
 PicoJsonValue()
   : value(emptyObject()) { }
コード例 #4
0
ファイル: json11_adapter.hpp プロジェクト: ansgri/valijson
 /// Construct a wrapper for the empty object singleton
 Json11Value()
     : value(emptyObject()) { }