Forum BigDB Trying to use JSON export as offline BigDB during developmen

Discussion and help relating to the PlayerIO database solution, BigDB.

Trying to use JSON export as offline BigDB during developmen

Postby CoderBrandon » May 20th, 2011, 5:40 pm

I'm often offline when I'm developing so it would be very useful for me if I could somehow use the JSON export of the BigDB and import it back in AS3 and C# and parse it into temporary BigDB data just so I can test locally on my laptop.

The problem I'm having is that the JSON export isn't actually valid, parseable JSON.. it doesn't pass any validation and I've yet to find a parser that could parse it correctly.. has anyone written a converter to make it valid?

Are there any plans on fixing the JSON export into valid JSON?

Oh, and being able to import the exported JSON back into the BigDB would make sense too. What's the point of a backup if you can't actually use it? :P
CoderBrandon
 
Posts: 6
Joined: April 22nd, 2011, 3:33 am
Location: Savannah, GA, USA

Re: Trying to use JSON export as offline BigDB during developmen

Postby Oliver » May 24th, 2011, 4:00 pm

Hey Brandon,

Can you be more specific about exactly why your json export fails? We can fix that then :-)

The whole reason we have export (and didn't bother to do import) is that we want you to feel secure that your data is, well, your data. That is, that you're able to get all your data out of the thing again in the long run.

Best,
Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Trying to use JSON export as offline BigDB during developmen

Postby CoderBrandon » May 24th, 2011, 5:14 pm

The JSON export from the admin works perfectly.. the problem I'm having is that I can't parse that data into AS3 or C# because it's not valid JSON.

Here is the export I get for my table "Buildings":
Code: Select all
Forge={
   description:"Allows you to work with metal",
   cost:12,
   size:{
      x:2,
      y:4
   },
   blueprints:{
      1:{
         MetalSheet:10
      }
   },
   name:"Forge"
}


If you run that through http://jsonlint.com/ (or any other validator), you get an error when attempting to parse.

If I was redoing the exporter, I would do use valid JSON syntax:
Code: Select all
{
   "Forge": {
      "description" : "Allows you to work with metal",
      "cost" : 12,
      "size" : {
         "x" : 2,
         "y" : 4
      },
      "blueprints": [
         {"MetalSheet" : 10}
      ],
      "name" : "Forge"   
   }
}


The only issue I see when converting would be that you lose DatabaseArrays with irregular indexes (ie values at indexes 0,5,33 and nowhere else).. but this could be solved by converting all arrays into objects and wrap the index number with quotes.

Example using the same blueprints DatabaseArray from above:
Code: Select all
"blueprints": {
   "1" : {"MetalSheet" : 10}
}
CoderBrandon
 
Posts: 6
Joined: April 22nd, 2011, 3:33 am
Location: Savannah, GA, USA

Re: Trying to use JSON export as offline BigDB during developmen

Postby Oliver » May 24th, 2011, 5:16 pm

Oh yea... i see.. Stupid us. Our json is not JSON it's just javascript object literals that should work if parsed by a browser.

Ehm... We'll get it fixed :-)

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Trying to use JSON export as offline BigDB during developmen

Postby CoderBrandon » May 24th, 2011, 5:23 pm

Awesome! Thanks guys.
CoderBrandon
 
Posts: 6
Joined: April 22nd, 2011, 3:33 am
Location: Savannah, GA, USA

Re: Trying to use JSON export as offline BigDB during developmen

Postby Henrik » June 15th, 2011, 12:53 pm

There we go. Try exporting a table now, and it should validate.

The only thing that might be unclear is how to handle dates. The JSON spec doesn't say how dates should be handled, and I chose to output them as strings, formatted like "yyyy-MM-dd HH:mm:ss", that shouldn't be a problem for anyone to parse, and it's easier to check for correctness rather than printing out the unix time.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Trying to use JSON export as offline BigDB during developmen

Postby CoderBrandon » June 17th, 2011, 10:25 pm

Perfect!

Thanks for the fix!
CoderBrandon
 
Posts: 6
Joined: April 22nd, 2011, 3:33 am
Location: Savannah, GA, USA


Return to BigDB



cron