Skip to content

Commit

Permalink
Add JK's example
Browse files Browse the repository at this point in the history
  • Loading branch information
Gene Gleyzer committed Nov 19, 2024
1 parent ab9a4d9 commit 2e9f272
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib_json/src/main/x/json.x
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module json.xtclang.org
/**
* JSON primitive types are all JSON values except for arrays and objects.
*/
// typedef (Nullable | Boolean | IntLiteral | FPLiteral | String) as Primitive;
typedef (Nullable | Boolean | IntLiteral | FPLiteral | String) as Primitive;

// or maybe:

Expand Down
61 changes: 38 additions & 23 deletions manualTests/src/main/x/TestSimple.x
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
module TestSimple {

package json import json.xtclang.org;

@Inject Console console;

import json.*;

void run() {

Test t = new Test();
console.print(t.getObject());
console.print(t.getDoc());

}

service Test {

JsonObject getObject(Int i = 1) {
JsonObject o = json.newObject();
o["a"] = i /*this will not be needed*/.toIntLiteral();
return o; // no need to freeze
}

Doc getDoc(Dec d = 1) {
JsonObject o = json.newObject();
o["a"] = d /*this will not be needed*/.toFPLiteral();
return o;
}
JsonObject o = json.newObject([
"status" = json.newObject([
"hostIP" = "10.0.10.4",
"hostIPs" = [
["ip" = "10.0.10.4"]
],
"conditions" = [
json.newObject([
"lastProbeTime" = Null,
"lastTransitionTime" = "2024-11-18T15:26:00Z",
"status" = False,
"type" = "PodReadyToStartContainers"
]),
json.newObject([
"lastProbeTime" = Null,
"lastTransitionTime" = "2024-11-18T15:26:00Z",
"message" = "containers with incomplete status: [coherence-k8s-utils]",
"reason" = "ContainersNotInitialized",
"status" = "False",
"type" = "Initialized"
]),
],
"containerStatuses" = [
json.newObject([
"image" = "ghcr.io/thegridman/test:1.0.0",
"imageID" = "",
"lastState" = [],
"name" = "coherence",
"ready" = False,
"restartCount" = 0,
"started" = False,
"state" = [
"waiting" = ["reason" = "PodInitializing"],
],
]),
],
]),
]);
}
}

0 comments on commit 2e9f272

Please sign in to comment.