Dissection of Hello World in Operon
Hello World is a classic first application that is written when learning new language. Here's the Hello World in Operon:
To run this, download the Operon-executable and you are good to go (nothing needs to be installed).
Let's go through this line by line:
As we can see, the query starts with the word "From". From is a keyword in Operon, and it tells from where we are going to get the data. Please note that the keywords in Operon start with the capital letters, so From has big F in it.
After From comes the input-source, which first in our examples is most of the time "json". You might be familiar with JSON already, but if you are not, then don't worry, you will learn it fast by going through the examples. Here we say that the input is a JSON-string, which has the value "Hello world!".
The From-statement is optional, so you may skip it. In this case the root-value will be an empty-value.
Each query must have the Select-statement. Here we have this dollar-symbol ($) after our Select-keyword. It means that we want to select root value, which means the value that was assigned by our input-source, and in this case it is a JSON-string "Hello world!".
- Finally we have the line which starts with hashtag-symbol, followed by the greater-than -symbol. Everything followed by the hashtag-symbol means that it is a comment. This is how we denote the query's output while going through examples.
Other content from Operon.io
Objects are like heart and soul of the JSON. You definitely want to know how to handle them effectively.
There's much you can do with arrays. Check out here your new set of JSON- array transformation functions!