Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/Json/JsonArray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package Json;

import java.util.ArrayList;
import java.util.List;

public class JsonArray implements JsonValue{
private List<JsonValue> a = new ArrayList<JsonValue>();
@Override
public JsonValue get(int i) throws JsonSyntaxException {
return null;
}

@Override
public JsonValue get(String s) throws JsonSyntaxException {
return null;
}

public List<JsonValue> getA() {
return a;
}

public void setA(List<JsonValue> a) {
this.a = a;
}
}
124 changes: 124 additions & 0 deletions src/Json/JsonBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package Json;

import static java.lang.Character.compare;
import static java.lang.Character.isDigit;

public class JsonBuilder implements JsonValue {
private CharScanner cs;
private JsonValue v;

public JsonBuilder() {
v=parseValue();



}

public JsonString parseString() throws JsonSyntaxException{
StringBuilder bild = new StringBuilder();
JsonString Jstr = new JsonString();
while (cs.hasNext()){
while(chCheck(cs.peek())!="Str"){
try {
bild.append(cs.next());
if(((Character)cs.peek()).equals('\')||((Character)cs.peek()).equals(' ')) {
if (cs.hasNext()){
cs.next();
}
else{
throw new JsonSyntaxException("kelet lo takin");
}
}
catch (JsonSyntaxException e) {
e.printStackTrace();
}
}



}
}
return arr;
}
public JsonArray parseArray() throws JsonSyntaxException{

JsonArray arr = new JsonArray();
while (cs.hasNext()){
while(chCheck(cs.peek())!="ArrayEnd"){
try {
arr.getA().add(parseValue());
while(((Character)cs.peek()).equals(',')||((Character)cs.peek()).equals(' ')) {
if (cs.hasNext()){
cs.next();
}
else{
throw new JsonSyntaxException("kelet lo takin");
}
}

}
catch (JsonSyntaxException e) {
e.printStackTrace();
}


}
}
return arr;
}
public JsonValue parseValue() throws JsonSyntaxException{
char ch;
if (this.cs.hasNext()) {
ch = this.cs.peek();
switch (chCheck(ch)) {
case "ArrayStart":
return parseArray();
case "Str":

case "AssoArrayStart":

case "Num":



}
;

}

}

public String chCheck(char ch) {

if (isDigit(ch) || ch == '-') {
return "Num";
}
if (ch == '[') {
return "ArrayStart";
}
if (ch == ']') {
return "ArrayEnd";
}
if (ch == '{') {
return "AssoArrayStart";
}
if (ch == '}') {
return "AssoArrayEnd";
}
if (ch == '"') {
return "Str";
}

return "Neutral";
}
@Override

public JsonValue get(int i) {
return null;
}

@Override
public JsonValue get(String s) {
return null;
}
}
13 changes: 13 additions & 0 deletions src/Json/JsonNumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package Json;

public class JsonNumber implements JsonValue {
@Override
public JsonValue get(int i) {
return null;
}

@Override
public JsonValue get(String s) {
return null;
}
}
24 changes: 24 additions & 0 deletions src/Json/JsonObject.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package Json;

import java.util.Map;

public class JsonObject implements JsonValue {
private Map<String, JsonValue> o;

@Override
public JsonValue get(int i) throws JsonSyntaxException {
return null;
}

@Override
public JsonValue get(String s) throws JsonSyntaxException {
return null;
}

@Override
public String toString() {
return "JsonObject{" +
"o=" + o.toString() +
'}';
}
}
4 changes: 4 additions & 0 deletions src/Json/JsonQueryException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package Json;

public class JsonQueryException extends Exception {
}
14 changes: 14 additions & 0 deletions src/Json/JsonString.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package Json;

public class JsonString implements JsonValue{

@Override
public JsonValue get(int i) {
return null;
}

@Override
public JsonValue get(String s) {
return null;
}
}
7 changes: 7 additions & 0 deletions src/Json/JsonSyntaxException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package Json;

public class JsonSyntaxException extends Exception {
public JsonSyntaxException(String message) {
super(message);
}
}
4 changes: 2 additions & 2 deletions src/Json/JsonValue.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Json;

public interface JsonValue {
public JsonValue get(int i);
public JsonValue get(String s);
public JsonValue get(int i) throws JsonSyntaxException;
public JsonValue get(String s) throws JsonSyntaxException;
}
6 changes: 0 additions & 6 deletions src/Json/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ public class Main {
//new code :

public static void main(String[] args) {
for (int i=0; i<2; i++){
System.out.println("waow");
}
System.out.println("hh");
System.out.println("dd");
System.out.println("dd");

}
}
Binary file added src/Json/Whiteboard[3]-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.