Reputation: 5173
Here's the value :
O:8:"stdClass":5:
{s:11:"origination";O:8:"stdClass":2:
{s:8:"username";s:9:"Prod";s:8:"password";s:8:"vi5";}
s:9:"serviceId";s:10:"9202501358";s:8:"elements";a:1:
{i:0;s:4:"3260";}s:11:"serviceKeys";a:6:
{i:0;O:8:"stdClass":2:
{s:2:"id";i:1;s:5:"value";s:10:"2102799679";}i:1;O:8:"stdClass":2:
{s:2:"id";i:1395;s:5:"value";s:0:"";}i:2;O:8:"stdClass":2:
{s:2:"id";i:1390;s:5:"value";s:0:"";}i:3;O:8:"stdClass":2:
{s:2:"id";i:1391;s:5:"value";s:0:"";}i:4;O:8:"stdClass":2:
{s:2:"id";i:1392;s:5:"value";s:0:"";}i:5;O:8:"stdClass":2:
{s:2:"id";i:1393;s:5:"value";s:0:"";}}s:7:"transId";s:1:"1";}
I'm trying to extract its value that store in mysql for variable named "data" ,
i'm not sure if this is json , but for json it would be something like .. without ";"
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
How can I extract this using python? I normally see xml where I used xpath : etree.XPath
to help extracting the value , But this format is new to me. couldn't figure it out where to start. Some recommendation would be greatly appreciated.
Upvotes: 0
Views: 700
Reputation: 770
It is a serialized PHP object. Example:
<?php
$obj = new stdClass();
$obj->coin = 'coin';
$obj->num = 1;
var_dump(serialize($obj)); ?>
gives:
string(55) "O:8:"stdClass":2:{s:4:"coin";s:4:"coin";s:3:"num";i:1;}"
Upvotes: 6