On Wednesday, October 7, 2015 at 10:46:40 AM UTC-4, nithish wrote:
>
> I am using memcached node js client. I am not getting the JSON output when 
> performing the get operation on it. Here is my code
>
> memcached.get(id, function( err, result ){
>   if( err ) console.error( err );
>   console.log( result );
> });
> and the output is 
>
>
> a:2:{s:7:"passkey";s:40:"8c779538d8c4ed54cf8a89d1e59518557febf0ac";s:7:"userkey";s:7:"5b9ce84";}
> How to get the userkey from this output or how to get the output as json?
>


The short answer: put JSON in to memcache if that's what you want to get 
back out.

Now looking at this, this is PHP Serialization format, using a PHP array 
(used as an object -- string keys) -- which means it's the same data that 
JSON can represent, represented as PHP Serialization instead. If you want 
to store JSON, you'll have to use PHP's json functions to get a string, and 
store that.

I suspect you're being bit by the special assumptions PHP's memcache driver 
does, where it serializes things you put in in some (or all) cases. PHP 
memcache drivers are remarkably full of magic for such a simple protocol.

You could also use a node decoder for PHP's format -- with simple objects 
that should be straightforward -- and just not use JSON.

Good luck! 

Aria

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/6e60a3c0-26b1-4046-8089-1f8b8f27d499%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to