The term Whitespace in C++ refers to the characters used for formatting, like creating spaces, tabs, and newlines. These are usually invisible in the source code output (meaning they don't appear in the actual program output); they just help to format the code and improve readability. Types of whitespace characters Here are the following four common types of whitespace characters mostly used in C++. Space (' ') Tab ('\t') Newline ('') Carriage return ('\r') Space (' ') It's a most basic whitespace ... Read More
‘Ik onkar’ or ‘Ek Onkar’ is a very sacred mantra for Sikhs all over the world. It is a basic mantra or a devotional hymn offered to their Lord. Also known as the 'mool' mantra , it is said to be Guru Nanak's first teaching sermon.What Does It Mean?The literal translation of "ik onkar satnam karta poorak nirabhu niravair akal murat ajuni saibham gur prasad jap Aadh Sach jugaad sach hai bhee sach nanak hose bhee sach " is that there is only one god, whose name is 'Truth'. He is the creator and is without fear. He is without ... Read More
The Russian Peasant multiplication is used to multiply two numbers without using the multiplication operator. It involves constant use of halving and doubling the numbers. In this article, we have two integers, our task is to find the product of these two integers by implementing russian peasant multiplication in C++. Steps to Implement Russian Peasant Multiplication We will follow these simple steps to find the product using Russian Peasant multiplication: We have created a function russianPeasant() that accepts both the numbers (n and m) as arguments. Then we used a ... Read More
Sometimes, we need to parse a nested JSON object, which means an object inside another object. In this article, let's learn about how to parse a nested JSON object in Java. If you don't know about JSON, refer JSON overview. Parsing a Nested JSON Object in Java? We can achieve this using some of the popular Java libraries. Those are listed below: Using org.json library : We will use jsonObject.getJSONObject method to parse a nested JSON object. Using Gson library : We will use JsonParser.parseString(json).getAsJsonObject(). Using Jackson library : In this, We will use ObjectMapper.readTree(json) method. Now, ... Read More
In this article, we will learn how to sort a JSON array in Java. But first, let’s understand what JSON is. If you do not have knowledge about JSON, you can refer to the tutorial JSON Overview. Now, let's see different ways to sort a JSON array in Java. Ways to sort a JSON array in Java Following are different ways to sort a JSON array in Java - Sort JSON array Without any Dependency Using org.json library: Methods are getJSONArray() and getJSONObject() Using Gson library: Methods ... Read More
We often need to extract values from a JSON object. In this article, we will learn how to get the values of the different types from a JSON object in Java. What is JSONObject? Java JSONObject is a class in the org.json package that represents a JSON object. Refer JSONObject for more information. Let's see the steps to get the values of different types from a JSON object in Java. Getting different values from a JSON object Before we start, let's add the required library to our program. We can add a .jar file, or we can use a Maven ... Read More
In this article, we will be discussing how to convert a list of objects to JSON using the Gson library in Java. JSON is an interchangeable format that is used for data exchange. Values in JSON are represented as key-value pairs. To know more about JSON, refer JSON. Java GSON Library: Converting a list of objects to JSON Gson is a third-party Java library developed by Google. It is used for converting Java objects to JSON and vice versa. In the Gson library, we can convert a list of objects to JSON using the toJson() method. We cannot use the ... Read More
Converting a map to a JSON object is our task here. Let's see how to convert a map to a JSON object in Java using the Gson library. Converting a Map to JSON using the Gson library JSON is a simple and lightweight data interchange format. It stores data in key-value pairs. A map is also a collection of key-value pairs. So, we can easily convert a map to a JSON object. If you are not familiar with JSON, refer JSON. And if you want to know more about Map, refer Map. Gson is developed by Google. It is an ... Read More
In this article, let's learn how to check if a JSON object has any values or not in Java. If you don't know about JSON, refer JSON. We will use the org.json library and its methods like isEmpty(), length(), and keys() to check if a JSON object is empty or not. We can check if a JSON object is empty or not using the following methods: Using isEmpty() method Using length() method Using keys() method Let's see how to use each of them one by one. ... Read More
JSON is a lightweight data interchange format. It is mostly used in web applications for sending and receiving data. To know more about JSON, refer JSON. A JSON array is a collection of JSON objects. It is similar to a list in Java. CSV is the format for storing tabular data in plain text. It is a comma-separated value. It is used for data exchange between applications. Let's see how CSV format looks like: JSON array The following is an example of the JSON array: [ { "Name": "Ansh", ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP