Exemple #1
0
 public function testdecodeTypedWithXSD_WithRootTypeAndNamespace()
 {
     global $JsonDASTest_error_handler_called;
     global $JsonDASTest_error_handler_severity;
     global $JsonDASTest_error_handler_msg;
     set_error_handler('JsonDASTest_user_error_handler');
     $JsonDASTest_error_handler_called = false;
     $exception_thrown = false;
     try {
         $json_das = new SDO_DAS_Json();
         $json_das->addTypesXsdFile(dirname(__FILE__) . "/Response.xsd");
         $sdo = $json_das->decode($this->json_mail_string, "ResponseType", "http://www.example.org/jsonrpc");
         $json_encoded_string = $json_das->encode($sdo);
         $this->assertTrue($json_encoded_string == $this->json_mail_string, 'encoded json string was: ' . $json_encoded_string . "\nbut should have been: " . $this->json_mail_string);
     } catch (Exception $e) {
         $this->assertTrue(false, "Exception was thrown from decodeTypedWithXSD_WithRootTypeAndNamespace test when it should not have been: " . $e->getMessage());
     }
     $this->assertFalse($JsonDASTest_error_handler_called, 'Error handler should not have been called for decodeTypedWithXSD_WithRootTypeAndNamespace test. Message was ' . $JsonDASTest_error_handler_msg);
 }
Exemple #2
0
        try {
            $item = $rss["channel/item[1]"];
        } catch (Exception $e) {
            // there are no items so $item will remain null.
        }
    } else {
        // and item has already been read and passed back into us
        // reconstitute the object sent from the browser
        $currentItem = $jsonDas->decode($objectString);
        // get the title from the object
        $title = $currentItem["title"];
        // find the next sibling of the item that matches the title
        $matchfound = false;
        foreach ($rss->channel->item as $rssitem) {
            if ($matchfound == true) {
                $item = $rssitem;
                break;
            }
            if ($rssitem->title == $title) {
                $matchfound = true;
            }
        }
    }
    if ($item == null) {
        $item = "No items in feed";
    }
    echo $jsonDas->encode($item);
} catch (Exception $e) {
    echo "Caught exception: \n";
    print_r($e);
}