Print

Print


David wrote:

>The problem is that for the two programming languages I use, Java and
> PHP the variable name key~ and $key~ is illegal, and I believe that is
> the case for most programming languages. Thus, in this PHP class (an its
> Java analog) would fail at compile / parse time:
<snip>
> Note that
> $query = json_encode(array('key~'=>'\/about\/*'));

> will not be parsed through the API, and results in an error message.


Hi David

In the PHP example that you gave, try changing it to:

$query = json_encode(array('key~'=>'/about/*'));

The slashes in that string gets escaped by the JSON ecoder. If you already escape them before encoding, it gets double-escaped to look like this:
{"key~":"\\\/about\\\/*"}
That is probably why you  got an error message from the API.

I don't think that this is an issue in almost all programming languages.  The point is that you don't want to name any variables 'key~' but this is just a string key in an associative array (or HashMap or dict whatever your programming language calls it). 

regards,

Etienne Posthumus
TU Delft Library