PHP Serialized Array Reader

I was just wondering if anyone in the community had something to read the PHP serialized array string data format.

They look like this:

Which roughly converts into:
Array of length One: (Index 0) of Array is a (String of length 1) with a value of “2”

But they get longer and more complicated obviously.
Here’s an example of a larger one in the DB:


As you can see it is not quite JSON but has similarities. Just trying to find the easiest way to convert this into something easily readable/usable in Xojo, whether that means stripping it and building a JsonItem or Variants I’m not too picky. Any thoughts or suggestions would be appreciated.

I don’t have PHP in scope and I’m getting these values directly from a MySQL DB. Even some stored_proc in MySQL to convert it to Json would work so I could read it on the Xojo side

If you have MBS, its PHP functions could help. I used MBS PHP to convert human dates into SQL Dates which was much cleaner than the Xojo Date classes. :slight_smile:

Unfortunately no and I’d rather avoid using MBS for this project

I found this website that does it:

But unfortunately I need to do it in code and not through a helper site

Can you use javascript in an HTMLViewer?

[quote=490460:@Hal Gumbert]Can you use javascript in an HTMLViewer?[/quote]

Unfortunately the “serialize” and “unserialize” are PHP specific commands not available in javascript.

I decided to make the Wordpress PHP side duplicate all the settings I need in the database with a “_json” suffix so I can read them easier:

$setting = get_user_meta($user_ID, $setting_name, true); $setting_json= json_encode($pm_group); update_user_meta($user_ID, $setting_name."_json", $setting_json);

Seems like you could extract the string from between the { and } chars, split it using the ; character and then parse each one… especially if they always come in threes.

Hey Brock,

Norm wrote one:

[quote=490475:@Hal Gumbert]Hey Brock,

Norm wrote one:[/quote]
Awesome, that helps! Thank Hal and thanks Norm!