code: private static JsonElement getJsonPrimitive(Object value, Class clazz)
      {
          if (value != null)
          {
              if (clazz.isAssignableFrom(Number.class) || value instanceof Number)
              {
                  return new JsonPrimitive((Number) value);
              }
              else if (clazz.isAssignableFrom(Boolean.class) || value instanceof Boolean)
              {
                  return new JsonPrimitive((Boolean) value);
              }
              else if (clazz.isAssignableFrom(Character.class) || value instanceof Character)
              {
                  return new JsonPrimitive((Character) value);
              }
              else if (clazz.isAssignableFrom(byte[].class) || value instanceof byte[])
              {
                  return new JsonPrimitive(PropertyAccessorFactory.STRING.fromBytes(String.class, (byte[]) value));
              }
              else
              {
                  return new JsonPrimitive(PropertyAccessorHelper.getString(value));
              }
          }
docs: Gets the json primitive.
  
  @param value
  the value
  @param clazz
  the clazz
  @return the json primitive