Skip to content

Commit

Permalink
1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
miktim committed Apr 4, 2022
1 parent 00ef9a9 commit f88105b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MIT License

Copyright (c) 2020-2022 [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
5 changes: 3 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Release notes:
- AVOID RECURSION!;
- in addition, the generator converts Java Lists,Sets to JSON arrays, Java Maps to JSON objects.
The null key is converted to a "null" member name.
Other Java objects are converted to JSON strings.
Other Java objects are converted to JSON strings;
- JSON JavaScript - like interface.

Put, set, get notes:
- put, set methods casts Java primitives to the corresponding objects.
Expand Down Expand Up @@ -50,7 +51,7 @@ Overview:

JSON normalize() throws Exception; // not required to generate JSON text

String stringify(String memberName, int... indices); // stringify value or array element
String toString(String memberName, int... indices); // stringify value or array element
String toString(); // overridden, stringify JSON object

Usage: see ./test/json/JSONTest.java
Binary file removed dist/json-1.2.0.jar
Binary file not shown.
Binary file added dist/json-1.2.1.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions src/org/miktim/JSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public String stringify() {
return stringify(this);
}

public String stringify(String memberName, int... indices) {
public String toString(String memberName, int... indices) {
return JSON.stringify(get(memberName, indices));
}

Expand All @@ -72,7 +72,7 @@ public List<String> listNames() {
return new ArrayList<>(this.keySet());
}

// Deprecated in 1.2.0
// Deprecated 1.2.0
@Deprecated
public List<String> list() {
return new ArrayList<>(this.keySet());
Expand Down
3 changes: 2 additions & 1 deletion test/json/JSONTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void main(String[] args) throws Exception {
log(json.getNumber("One").floatValue()); // Number(Integer)
// java.lang.ClassCastException
// log(json.getString("Two"));
log(json.stringify("Two"));
log(json.toString("Two"));
log(json.getString("3"));
log(json.getJSON("Nested").getNumber("Array", 1, 1).intValue());

Expand Down Expand Up @@ -94,6 +94,7 @@ public static void main(String[] args) throws Exception {
log(json.getNumber("Array", 1, 1).floatValue());

log(json = json.normalize());

log(json.get("Array").getClass().getSimpleName());
// array is instance of Object[]
log(json.getNumber("Array", 1, 1).floatValue());
Expand Down

0 comments on commit f88105b

Please sign in to comment.