Skip to content

Commit

Permalink
Introduction text
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Azpillaga Aldalur committed Dec 3, 2023
1 parent 9a7eef9 commit e2d1f13
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/onpush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 12
node-version: 18

- name: Build project
run: npm install && npm run generateParser && npm run createDistribution && npm run bundle
Expand Down
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
# Build an advanced JSON validator website with Tylasu

## Motivation
## Introduction

As developers, most of us are familiar with JSON.
It has become the standard data representation format.
In fact, it is likely that you have more than once wandered whether a piece of JSON data is valid.
Or whether it has all the information that you expect.
It has become the go-to format to represent data.
Chances are, that you have at some point wanted to check some JSON data.
To make sure it is valid and it contains all the information you expect.

Some existing websites like [jsonlint] or [jsonformatter] offer you the ability to validate JSON data.
Some existing websites like [jsonlint] or [jsonformatter] offer you exactly that.
But have you ever wondered how you could build such a website?
Of course, there are million ways to do it. But choosing the right tools can make the task become easy, even fun.
Of course, there are a million ways to do it. But choosing the right tools can make the task become easy, even fun.

Here at Strumenta, we build all kind of tools, and data validators are no exception.
In this tutorial, we will show you how to leverage the power of Tylasu, ANTLR and Monaco, all open source tools, to build a friendly JSON validator website.
Here is what it looks like:

![colored json]
![Colored JSON validator with an error](introduction-1.png)

You can play with it online at https://strumenta.github.io/tylasu-tutorial

It is a website that looks and acts like an editor.
Whenever you type on it, it parses the code expecting some JSON.
If incorrect, it underlines the "confronting" code part that show the error message on hover.
It colors each member depending on the type of its value.
It displays error markers over the conflicting code, and colors each member depending on the type of its value.

It even has a secret feature:
If the code is a JSON object with a `"applyConfiguration": true` member, the code will be interpreted as monaco editor configuration and applied to the editor on the spot.
If a `"applyMonacoConfiguration": true` member is present, the code will be interpreted as monaco editor configuration and applied to the editor on the spot.
Try changing the font size or the editor's theme like this:

![editor configuration]
![editor configuration example](introduction-2)

As with every tutorial we create, the entire codebase is hosted on [Github].
The repo has a tag for each of the 5 steps on this tutorial to check your progress or skip a step completely.
To follow the tutorial on your machine, you will need Node and Java installed.
Ready? Let's start:
The complete codebase is on [Github], with a dedicated git tag for each of the 7 tutorial steps. Use them to check your progress or skip over steps completely.
Everything ready? Let's start:

## 1. Create the editor

I am a huge believer in having something visual and interactive to play with as soon as possible when I develop programs.
I am a huge believer in having something visual and interactive to play with as soon as possible whenever I develop programs.
So, let's start with the editor.
It is a regular HTML, CSS and JS static website.
Let's create the files in the root folder:
Expand Down Expand Up @@ -383,7 +381,7 @@ Tylasu offers more facilities to test and serialize ASTs to create more professi
Want more ideas on how to apply these new techniques you learned?
We have many articles about creating compilers etc.


[image]: ./image.png
[jsonlint]: https://jsonlint.com/
[jsonformatter]: https://jsonformatter.curiousconcept.com/
[Github]: https://github.com/strumenta/tylasu-tutorial
Expand Down
Binary file added introduction-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e2d1f13

Please sign in to comment.