JSON2HTML Jump Start PRO

The JSON2HTML JavaScript open source library provides us with a powerful templating system we can use to convert JSON objects into HTML.

The following code sample shows how simple it is to use this library for the purpose of converting data we hold in JSON objects into HTML.

<!DOCTYPE html>
<html>
<head>
    <title>json2html demo</title>
    <script type="text/javascript"
            src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
    </script>
    <script type="text/javascript" src="json2html.js"></script>
    <script type="text/javascript" src="jquery.json2html.js"></script>
</head>
<body>
<script type="text/javascript">
    var template = {'tag':'li','html':'${abbreviation} - ${explanation}'};

    var data = [
        {'abbreviation':'IMHO','explanation':'In My Humble Opinion'},
        {'abbreviation':'FYI','explanation':'For Your Information'},
        {'abbreviation':'CYE','explanation':'Check Your Email'},
        {'abbreviation':'GIY','explanation':'Google It Yourself'},
        {'abbreviation':'4YEO','explanation':'For Your Eyes Only'}
    ];

    var str = json2html.transform(data,template);

    document.write(str);
</script>
</body>
</html>

The followinb video clip overviews this code sample, shows its execution and explains each and every part of it.

You can find the entire code sample ready for download in my JSON2HTML course at http://abelski.lifemichael.com.

Share:

The Visitor Design Pattern

The Visitor Design Pattern

The visitor design pattern allows us to add operations to objects that already exist without modifying their classes and without extending them.

What are Anti Patterns?

Anti Patterns

Unlike design patterns, anti patterns just seem to be a solution. However, they are not a solution and they cause additional costs.

Virtual Threads in Java Professional Seminar

Virtual Threads in Java

The use of virtual threads can assist us with improving the performance of our code. Learn how to use virtual threads effectively.

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Update cookies preferences