Beispiel #1
0
static void debug_print_object(int number) {
	int i;
	zword_t addr, len;
	
    glk_printf("Object %d:\nName: \"", number);
    print_object_name(number);
    glk_put_string("\"\nAttributes: ");
	for (i = 0; i < (zGameVersion < Z_VERSION_4 ? 32 : 48); i++) {
		if (get_attribute(number, i))
			glk_printf("%d ", i);
	} 
    glk_printf("\nParent: %3d \"", object_parent(number));
    print_object_name(object_parent(number));
    glk_printf("\"\nSibling: %3d \"", object_sibling(number));
    print_object_name(object_sibling(number));
    glk_printf("\"\nChild: %3d \"", object_child(number));
    print_object_name(object_child(number));
    glk_put_string("\"\nProperties:\n");
	i = 0;
	while (i = get_next_property(number, i)) {
		glk_printf("    [%2d] ", i);
		addr = get_property_address(number, i);
		for (len = get_property_length(addr); len > 0; len--)
			glk_printf("%02x ", get_byte(addr++));
		glk_put_string("\n");
	}
}
Beispiel #2
0
void VJSONValue::test()
{
    const char *sTestJson = "{\"good\":true,\"name\":\"smith\",\"paul\":{\"good\":false,\"name\":\"paul\",\"Nul\":null,\"age\":10.321,\"text\":\"\"\\/\b\f\n\r\t\"},\"age\":42}";

    VJSONValue	object( JSON_object);

    object.SetProperty( CVSTR( "name"), VJSONValue( CVSTR( "smith")));
    object.SetProperty( CVSTR( "age"), VJSONValue( 42));
    object.SetProperty( CVSTR( "good"), VJSONValue::sTrue);

    for( VJSONPropertyIterator i( object.GetObject()) ; i.IsValid() ; ++i)
    {
        VString propertyName = i.GetName();
        VJSONValue propertyValue = i.GetValue();
    }

    VJSONValue	object_child( JSON_object);

    object_child.SetProperty( CVSTR( "name"), VJSONValue( CVSTR( "paul")));
    object_child.SetProperty( CVSTR( "age"), VJSONValue( 10.321));
    object_child.SetProperty( CVSTR( "good"), VJSONValue::sFalse);
    object_child.SetProperty( CVSTR( "text"), VJSONValue( CVSTR( "\"\\/\b\f\n\r\t")));
    object_child.SetProperty( CVSTR( "Nul"), VJSONValue::sNull);
    object_child.SetProperty( CVSTR( "undef"), VJSONValue::sUndefined);

    VJSONArray		*object_children = new VJSONArray;
    object_children->Push( object_child);

    object.SetProperty( CVSTR( "children"), VJSONValue( object_children));

    ReleaseRefCountable( &object_children);

    VString s;
    VJSONWriter writer( JSON_WithQuotesIfNecessary);
    VError err = writer.StringifyValue( object, s);

    DebugMsg( s);
    DebugMsg( "\n");

    VJSONWriter writer2( JSON_WithQuotesIfNecessary | JSON_PrettyFormatting);
    err = writer2.StringifyValue( object, s);

    DebugMsg( s);
    DebugMsg( "\n");

    VJSONValue value;
    VJSONImporter importer(s);
    err = importer.Parse( value);
    VString s2;
    writer2.StringifyValue( value, s2);
    DebugMsg( s2);
    DebugMsg( "\n");
    xbox_assert( s == s2);

    {
        VJSONImporter importer2( CVSTR( "[1,2,3,[4,5],6]"));
        err = importer2.Parse( value);
        value.GetString( s2);
        DebugMsg( s2);
        DebugMsg( "\n");
    }

}