Code example for JsonPrimitive

0
			.compile("\\s*\\(\\s*(.+?)\\s*,\\s*(.+?)\\s*\\)\\s*");
	 
	@Override 
	public JsonElement serialize(Point src, Type typeOfSrc,
			JsonSerializationContext context) {
		return new JsonPrimitive("(" + src.x + ", " + src.y + ")");
	} 
	 
	@Override 
	public Point deserialize(JsonElement json, Type typeOfT,
			JsonDeserializationContext context) throws JsonParseException {
		String string = json.getAsString();
		Matcher matcher = POINT_PATTERN.matcher(string);
		if (!matcher.matches())
			throw new JsonParseException("Malformed point");
		int x = Integer.parseInt(matcher.group(1));
		int y = Integer.parseInt(matcher.group(2));
		return new Point(x, y);
	} 
	 
Experience pair programming with AI  Get Codota for Java