problem with JSON-RPC

Diez B. Roggisch deets at nospam.web.de
Wed Nov 12 09:59:40 EST 2008


Michel Perez wrote:

> Hi everybody:
>  I'm trying to use JSON-RPC to provide my services but produce this
> exception:
> 
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "jsonrpc/proxy.py", line 43, in __call__
>     resp = loads(respdata)
>   File "jsonrpc/json.py", line 211, in loads
>     raise JSONDecodeException('Expected []{}," or Number, Null, False or
> True')
> jsonrpc.json.JSONDecodeException: Expected []{}," or Number, Null, False
> or True
> 
> 
> This is what am doing
> 
> 
> ==== configuration file for apache ====
> <code lang="apache.conf">
> Alias /services/ //home/mperez/Desktop/test_jsonrpc/
> 
> <Location /services/>
>     Options Indexes MultiViews FollowSymLinks
>     Order deny,allow
> Allow from All
>     
>     AddHandler mod_python .py
>     PythonHandler jsonrpc
> </Location>
> </code>
> 
> ==== service for jsonrpc test.py ====
> <code lang="python">
> from jsonrpc import ServiceMethod
> 
> class MyService(object):
>     @ServiceMethod
>     def echo(self, msg):
>         return msg
> 
> service = MyService()
> </code>
> 
> ==== service client ====
> <code lang="python">
> #!/usr/bin/env python
> from jsonrpc import ServiceProxy
> s = ServiceProxy("http://localhost/services/test.py")
> print s.echo("foobar")

Try s.echo("'foobar'")

JSON needs quotes around string-literals.

Diez



More information about the Python-list mailing list