View previous topic :: View next topic |
Author |
Message |
Ligustah
Joined: 21 Oct 2007 Posts: 45 Location: Berlin, Germany
|
Posted: Mon Oct 29, 2007 6:46 pm Post subject: toJSON api function |
|
|
Hi!
I'm missing a toJSON function in the MiniD api. I need it for saving some information about my scripts. I want my scripts to have these information, so i load them from a table out of a file. For saving this table i need something like toJSON in the api.
Mfg Ligustah |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon Oct 29, 2007 9:10 pm Post subject: |
|
|
Another good idea. In the meantime you can do the following:
Code: |
MDString toJSON(T)(MDState s, T r)
{
static if(is(T : MDTable) || is(T : MDArray))
alias r root;
else
MDValue root = r;
s.easyCall(s.context.globals["toJSON"d], 1, MDValue(null), root);
return s.pop().to!(MDString);
}
// Use like this:
MDTable t = MDTable.create
(
"foo", "bar",
"baz", 5,
"array", MDArray.create(1, 2, 3.4)
);
Stdout.formatln("{}", toJSON(ctx.mainThread, t));
|
|
|
Back to top |
|
|
Ligustah
Joined: 21 Oct 2007 Posts: 45 Location: Berlin, Germany
|
Posted: Tue Oct 30, 2007 5:31 am Post subject: |
|
|
Thx. Looks quite simple. I'll use it, waiting for a real toJSON api function
Mfg Ligustah |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|