Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Storing Json In Database

json

  • Please log in to reply
4 replies to this topic

#1 mctim

mctim

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 110 posts

Posted 27 June 2012 - 06:03 PM

I did a quick google and found this. I have basically the same question. Can this be done is? Is it a bad idea? If you want some insight on my thought process I'm implementing a very simple Q&D job scheduler, and at least for my use case I'll need to parameterize the jobs as well as persist them. That being said, my plan at this point is to store all the job parameters as a JSON in the database and then just load them up the next time the job needs to run.
  • 0

#2 mctim

mctim

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 110 posts

Posted 27 June 2012 - 10:15 PM

Another idea i had was to save the HTTP request that the scheduler gets and then give it to the job when it runs which would allow the job to search for any parameters it finds interesting. Again is this a "bad" idea?
  • 0

#3 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 28 June 2012 - 04:38 AM

I see no problem in saving the JSON in an database. especially if it's static data. first rule of data saving is to keep it simple and manageable. The more complex data, the more complex storage. if you need to send some plain JSON to a browser which is prestored in a db, it's perfect usage of simple storage.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#4 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 28 June 2012 - 07:04 AM

Can it be done? Sure, using a CLOB.

Should it be done? Probably not. It makes more sense to me to store the elements in a database, rather than a CLOB that you hope is meaningful. You can't report against the JSON data easily, for example.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#5 mctim

mctim

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 110 posts

Posted 28 June 2012 - 08:25 AM

Should it be done? Probably not. It makes more sense to me to store the elements in a database, rather than a CLOB that you hope is meaningful. You can't report against the JSON data easily, for example


The reason why I like this solution as apposed to making several tables, foreign keys, ect, is because what I am representing is in the table is an abstract cl**. Therefore what you would be essentially asking me to do, by implementing another table to store the extending cl**es needed params, is implement an infinite number of tables. This is the reason because you could essentially extend the class in anyway you feel.
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download