com.yworks.yfiles.server.tiles.support
Class JSONSupport

java.lang.Object
  extended bycom.yworks.yfiles.server.tiles.support.JSONSupport

public class JSONSupport
extends Object

Provides static utility methods for JSON encoding

See Also:
JSON Spec

Method Summary
static String escapeString(String str)
          Escapes the given string according to the JSON format specification.
static String escapeStringNoQuotes(String str)
          Escapes the given string according to the JSON format specification.
static String pointString(YPoint point)
          returns a string in JSON format for the given point.
static String rectangleString(Rectangle rectangle)
          returns a string in JSON format for the given rectangle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

escapeString

public static String escapeString(String str)
Escapes the given string according to the JSON format specification. This method also surrounds the string with double quotes. For transferring unicode characters, the respone content type has to be set accordingly, e.g. response.setContentType("text/plain;charset=UTF-8");.

Parameters:
str - The string to be escaped.
Returns:
The escaped string that can be used as a value in a JSON object.

escapeStringNoQuotes

public static String escapeStringNoQuotes(String str)
Escapes the given string according to the JSON format specification. This method does not surround the string with double quotes. For transferring unicode characters, the respone content type has to be set accordingly, e.g. response.setContentType("text/plain;charset=UTF-8");.

Parameters:
str - The string to be escaped.
Returns:
The escaped string that can be used as a value in a JSON object.

rectangleString

public static String rectangleString(Rectangle rectangle)
returns a string in JSON format for the given rectangle. If the rectangle is null, null is returned.

Example:
{"x":0,"y":0,"width":300,"height":500}

Parameters:
rectangle - a rectangle
Returns:
a JSON string or null

pointString

public static String pointString(YPoint point)
returns a string in JSON format for the given point. If the rectangle is null, null is returned.

Example:
{"x":17,"y":42}

Parameters:
point - a point
Returns:
a JSON string or null


Copyright © 2006-2013 yWorks GmbH. All rights reserved