Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7740087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:41:06+00:00 2026-06-01T08:41:06+00:00

I recently started using Riak with PHP. How exactly do I store JSON data?!

  • 0

I recently started using Riak with PHP.

How exactly do I store JSON data?! Do I just push the JSON string into a Riak Object?!

The Riak PHP Client has the following for storing data:

require_once('riak-php-client/riak.php');

# Connect to Riak
$client = new RiakClient('127.0.0.1', 8098);

# Choose a bucket name
$bucket = $client->bucket('test');

# Supply a key under which to store your data
$person = $bucket->newObject('riak_developer_1', array(
    'name' => "John Smith",
    'age' => 28,
    'company' => "Facebook"
));

# Save the object to Riak
$person->store();

This takes the form of key-array data. So in the case of JSON, would it be like below?

# Supply a key under which to store your data
$person = $bucket->newObject('riak_developer_1', '{"name": "John Smith", "age": "28", "company": "Facebook"}';

I’m trying to find the best way to store data in the event that I need to use Riak’s Search feature. I’m also unsure if map-reduce works better/faster this way?!

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:41:08+00:00Added an answer on June 1, 2026 at 8:41 am

    The array is already being converted to JSON in RiakObject->store() by default; you don’t have to do anything.

    If you look at the PHP client source, you’ll see json_encode() is being used in the store() method when jsonize is TRUE (Which is the case when you use RiakBucket->newObject() ):
    https://github.com/basho/riak-php-client/blob/master/riak.php#L1513

    If you were to to do the following in your browser (after storing your array):

    http://127.0.0.1:8098/riak/test/riak_developer_1

    You’d get back:

    {“name”: “John Smith”, “age”: 28, “company”: “Facebook”}

    When you fetch the data back out of Riak using the PHP client it’s doing the reverse and you end up with your original PHP array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently started using R and am still getting used to its data
I just recently started using this library (the one from CodePlex), but I ran
I recently started using Eclipse for PHP Development. Please suggest me some HTML WYSIWYG
I recently started using android actionbars and contextual action bars (CAB). I have just
I recently started using the DisplayTag library and I've run into a problem. I'm
I've just recently started using VS2008 for a new tools project, and have been
I've recently started using Magento for a client's webshop, and still need to get
I just recently started using Hudson as a CI server for a project of
I've just recently started using SQLAlchemy and am still having trouble wrapping my head
I've recently started using Ruby and was told to look into using RVM. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.