Skip to content

Commit

Permalink
Updater Jsoner for colors
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitgaudou committed May 8, 2022
1 parent c234f79 commit f8a3dce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 11 additions & 3 deletions msi.gama.core/src/msi/gama/util/file/json/Jsoner.java
Expand Up @@ -744,8 +744,16 @@ private static void serialize(final Object jsonSerializable, final Writer writab
writableDestination.write(jsonSerializable.toString());
} else if (jsonSerializable instanceof Boolean) {
writableDestination.write(jsonSerializable.toString());
// } else if (jsonSerializable instanceof GamaColor) {
//
} else if (jsonSerializable instanceof GamaColor) {
GamaColor col = (GamaColor) jsonSerializable;
writableDestination.write('{');
writableDestination.write('"'+"r"+'"'+":");
Jsoner.serialize(col.red(), writableDestination, flags);
writableDestination.write("," + '"'+"g"+'"'+":");
Jsoner.serialize(col.blue(), writableDestination, flags);
writableDestination.write("," + '"'+"b"+'"'+":");
Jsoner.serialize(col.green(), writableDestination, flags);
writableDestination.write('}');
} else if (jsonSerializable instanceof Map) {
/* Writes the map in JSON object format. */
boolean isFirstEntry = true;
Expand Down Expand Up @@ -975,7 +983,7 @@ private static void serialize(final Object jsonSerializable, final Writer writab
// + " that isn't JSON serializable.\n Try:\n 1) Implementing the Jsonable interface for the object to return valid JSON. If it already does it probably has a bug.\n 2) If you cannot edit the source of the object or couple it with this library consider wrapping it in a class that does implement the Jsonable interface.\n 3) Otherwise convert it to a boolean, null, number, JsonArray, JsonObject, or String value before serializing it.\n 4) If you feel it should have serialized you could use a more tolerant serialization for debugging purposes.");
// }
// }
// System.out.println(writableDestination.toString());
// System.out.println(writableDestination.toString());
}

/** The Constant NON_SAVEABLE_ATTRIBUTE_NAMES. */
Expand Down
Expand Up @@ -25,9 +25,9 @@ species NetworkingAgent skills:[network] {
reflex send when: cycle = 0 {
write "sending message ";

// do send to: "/api/user/" contents: ["POST",map(["toto"::34,"titi"::12]), map(["Content-Type"::"application/json"])];
// do send to: "/api/user/" contents: ["PUT",map(["toto"::34,"titi"::12]), map(["Content-Type"::"application/json"])];
do send to: "/api/user/" contents: ["DELETE"];
do send to: "/api/user/" contents: ["POST",["toto"::34,"titi"::world], ["Content-Type"::"application/json"] ];
// do send to: "/api/user/" contents: ["PUT",["toto"::34,"titi"::12], ["Content-Type"::"application/json"]];
// do send to: "/api/user/" contents: ["DELETE"];

}

Expand Down

0 comments on commit f8a3dce

Please sign in to comment.