Get JSON Object Data

To get JSON data using JavaScript for data stored as JSON string in the database you can use

for(var i = 0; i < modules.length; i++) {
    var moduleJSON = modules[i].json; // JSON string
    var parsedModule = JSON.parse(moduleJSON); // JSON Object

modules is the name for data objects here but it could of course be another denominator. Now, first you do a for loop to check if the length is larger than 0 for the JSOn string. If so you continue by loading the JSON string in a variable moduleJSON. Or.. another name.

Then you parse the JSON string and turn it into a JSON object you can then work with. In this case it would be called parsedModule. That is the object.

Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.