PHP Append Functionality Broke

Greetings,
So it looks like append functionality is broke with the PHP API.
This works:

<?php $cb = new Couchbase("couchbase1:8091", "", "", "default"); $array['test1'] = array("One", "Two", "Three"); $array['test2'] = array("A", "B", "C"); $array = json_encode($array); $cb->set("test", $array); $result = json_decode($cb->get("test"), TRUE); print_r($result); /* $updated['testappend'] = array("Append 1", "Append 2"); $updated = json_encode($updated); $cb->append("test", $updated); $result = json_decode($cb->get("test"), TRUE); print_r($result); */ ?> When viewing the document in the web interface, all is good: { "test1": [ "One", "Two", "Three" ], "test2": [ "A", "B", "C" ] } However, when I uncomment the append section and run the script: <?php $cb = new Couchbase("couchbase1:8091", "", "", "default");
    $array['test1'] = array("One", "Two", "Three");
    $array['test2'] = array("A", "B", "C");
    $array = json_encode($array);

    $cb->set("test", $array);
    $result = json_decode($cb->get("test"), TRUE);
    print_r($result);


    $updated['testappend'] = array("Append 1", "Append 2");
    $updated = json_encode($updated);

    $cb->append("test", $updated);
    $result = json_decode($cb->get("test"), TRUE);
    print_r($result);

?>


This is what I get when I look at the document now:

“eyJ0ZXN0MSI6WyJPbmUiLCJUd28iLCJUaHJlZSJdLCJ0ZXN0MiI6WyJBIiwiQiIsIkMiXX17InRlc3RhcHBlbmQiOlsiQXBwZW5kIDEiLCJBcHBlbmQgMiJdfQ==”

Thoughts? I am just starting with Couchbase, is there something I’m missing, or is the method indeed broke?
Thanks!
-Jason

Hello,
This is due to the fact that the “append()” operation has nothing to do with JSON.
It allows you to append “bytes” at the end of the “bytes” that are store in Couchbase.
As you may know, you can store anything into Couchbase : binary, text, numbers,… and JSON,and the append/prepend is just done on the value not the “JSON”.
If you look at the String (do not json_decode) you will see something like

{
“test1”: [
“One”,
“Two”,
“Three”
],
“test2”: [
“A”,
“B”,
“C”
]
}
{
“Append 1”, "Append 2
}

if you want to append a JSON array you have to use JSON in your code and do a set/replace into Couchbase.
Take a look to this sample code:
https://github.com/couchbaselabs/DeveloperDay/blob/master/PHP/06_nonjson
Regards