Minor Adjustments Example.md

Added syntax highlighting, standardised indentation
This commit is contained in:
TheCommandBlock 2022-10-06 00:48:34 +02:00 committed by GitHub
parent 8439039da7
commit 61801c623e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
<h1>Examples</h1>
<p>Imports used in the examples: </p>
```
```java
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@ -14,7 +14,7 @@ import java.util.Properties;
<h3>Using JSONArray</h3>
```
```java
private static void JSONExampleArray1() {
//We create a JSONObject from a String containing an array using JSONArray
//Firstly, we declare an Array in a String
@ -57,7 +57,7 @@ import java.util.Properties;
return res;
}
```
```
```java
private static void JSONExampleArray2() {
//We can also create an Array without a String by creating an empty array and adding elements to it
@ -81,7 +81,7 @@ import java.util.Properties;
<h3>Using JSONStringer</h3>
```
```java
private static void JSONExampleStringer() {
//We initializate the JSONStringer
@ -116,7 +116,7 @@ import java.util.Properties;
```
<h3>Using JSONObject</h3>
```
```java
private static void JSONExampleObject1() {
//We can create a JSONObject from a String with the class builder
@ -127,7 +127,7 @@ import java.util.Properties;
}
```
```
```java
private static void JSONExampleObject2() {
//We can also create a JSONObject directly without messing around with any of the other functions.
@ -151,7 +151,7 @@ import java.util.Properties;
System.out.println("Final JSONOBject: " + example);
}
```
```
```java
private static void JSONExampleObject3() {
//We can also create a JSONObject with a Java Map
@ -170,7 +170,7 @@ import java.util.Properties;
```
<h3>Using JSONWriter</h3>
```
```java
private static void JSONExamplWriter() {
//This method works in a very similar way to Object and Stringer in the construction of the JSON.
@ -202,7 +202,7 @@ import java.util.Properties;
}
```
```
```java
private static void JSONExampleTokener() {
//A partir de una String podemos crear un JSONTokener, que lo podemos usar alternativamente para JSONArray,JSONObject
@ -223,7 +223,7 @@ import java.util.Properties;
<h3>Extra: Conversion to JSONArray</h3>
```
```java
private static void JSONObjectToArray() {
//We start with a JSONObject
@ -244,7 +244,7 @@ import java.util.Properties;
```
<h3>XML Conversions</h3>
```
```java
private static void XMLToExampleConversion() {
//We start with a JSONObject
@ -258,7 +258,7 @@ import java.util.Properties;
System.out.println("Final XML: " + output);
}
```
```
```java
private static void XMLFromExampleConversion() {
//We start with a string with the XML format
@ -274,7 +274,7 @@ import java.util.Properties;
```
<h3>Cookie Conversions</h3>
```
```java
private static void CookieToExampleConversion() {
//We start with a JSONObject
@ -290,7 +290,7 @@ import java.util.Properties;
System.out.println("Final Cookie: " + output);
}
```
```
```java
private static void CookieFromExampleConversion() {
//We start with a string with the Cookie format
@ -306,7 +306,7 @@ import java.util.Properties;
<h3>HTTP Conversions</h3>
```
```java
private static void HTTPToExampleConversion() {
//We start with a JSONObject
@ -322,7 +322,7 @@ import java.util.Properties;
System.out.println("Final HTTP: " + output);
}
```
```
```java
private static void HTTPFromExampleConversion() {
//We start with a string with the HTTP format
@ -337,7 +337,7 @@ import java.util.Properties;
```
<h3>CDL Conversions</h3>
```
```java
private static void CDLToExampleConversion() {
//We start with some JSONObjects with the same values in the keys but different values in the "values"
@ -360,7 +360,7 @@ private static void CDLToExampleConversion() {
System.out.println("Final CDL: \r\n" + output);
}
```
```
```java
private static void CDLFromExampleConversion() {
//We start wtih a String with the CDL format
@ -377,7 +377,7 @@ private static void CDLFromExampleConversion() {
```
<h3>Properties Conversions</h3>
```
```java
private static Properties PropertyToExampleConversion() {
//We start with a JSONObject
@ -393,7 +393,7 @@ private static void CDLFromExampleConversion() {
return output;
}
```
```
```java
private static void PropertyFromExampleConversion() {
//We start with a Properties object
@ -408,7 +408,7 @@ private static void CDLFromExampleConversion() {
```
<h2>List of all examples methods</h2>
```
```java
public static void main(String[] args) {
//JSONObjectToArray();
//JSONExampleArray1();