Parsing payload

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
spyke11
Posts: 1
Joined: Sat Jul 20, 2013 11:06 am

Parsing payload

Post by spyke11 » Sat Jul 20, 2013 11:13 am

Hi,
i'm novice in python's programmation...
I want to split eg.event.payload but the script return me this error :

AttributeError: AutoRemotePayload instance has no attribute 'split'

i use this script:

p = eg.event.payload
p = p.split(',')

the payload is "params: [u'Test', u'salut']; command(s): ;"

what's wrong , Can you help me please ?

piert
Experienced User
Posts: 313
Joined: Tue Jun 14, 2011 2:53 pm

Re: Parsing payload

Post by piert » Sat Jul 20, 2013 2:03 pm

i use this script:

p = eg.event.payload
p = p.split(',')

the payload is "params: [u'Test', u'salut']; command(s): ;"

what's wrong , Can you help me please ?
Maybe you need to split your result first by using semicolon as a separator and post back your results.

piert
Experienced User
Posts: 313
Joined: Tue Jun 14, 2011 2:53 pm

Re: Parsing payload

Post by piert » Sat Jul 20, 2013 2:27 pm

And by that I mean:

p = eg.event.payload
p = p.split(';')
print p[0]
print p[1]

If that works, you might get a result by adding q = p[0] .split(',')

Sem;colon
Experienced User
Posts: 609
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Parsing payload

Post by Sem;colon » Sat Jul 27, 2013 11:47 am

hmm, it looks like your payload is a dictionary with a list - maybe you could try something like:
p=eg.event.payload["params"][0]

if you want to use split try:
p = str(eg.event.payload)
p = p.split(',')

Post Reply