Codota Logo
jodd.json
Code IndexAdd Codota to your IDE (free)

How to use jodd.json

Best Java code snippets using jodd.json (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: oblac/jodd

/**
 * {@inheritDoc}
 */
@Override
public void writeComma() {
  JsonValueContext valueContext = peekValueContext();
  if (valueContext != null) {
    valueContext.incrementIndex();
  }
  super.writeComma();
}
origin: oblac/jodd

/**
 * {@inheritDoc}
 */
@Override
public void pushName(final String name, final boolean withComma) {
  JsonValueContext valueContext = peekValueContext();
  if (valueContext != null) {
    valueContext.setPropertyName(name);
  }
  super.pushName(name, withComma);
}
origin: oblac/jodd

/**
 * Parses input JSON to {@link JsonArray}, special case of parsing.
 */
public JsonArray parseAsJsonArray(final String input) {
  return new JsonArray(parse(input));
}
origin: oblac/jodd

/**
 * Parses input JSON to {@link JsonObject}, special case of {@link #parse(String, Class)}.
 */
public JsonObject parseAsJsonObject(final String input) {
  return new JsonObject(parse(input));
}
origin: oblac/jodd

@Override
public void serializeValue(final JsonContext jsonContext, final Object value) {
  jsonContext.writeOpenObject();
  BeanSerializer beanVisitor = new BeanSerializer(jsonContext, value);
  beanVisitor.serialize();
  jsonContext.writeCloseObject();
}
origin: oblac/jodd

private JsonObject createJsonObject() {
  JsonObject obj = new JsonObject();
  obj.put("mystr", "bar");
  obj.put("myint", Integer.MAX_VALUE);
  obj.put("mylong", Long.MAX_VALUE);
  obj.put("myfloat", Float.MAX_VALUE);
  obj.put("mydouble", Double.MAX_VALUE);
  obj.put("myboolean", true);
  obj.put("mybinary", randomByteArray(100));
  return obj;
}
origin: oblac/jodd

/**
 * Static ctor.
 */
public static JsonSerializer create() {
  return new JsonSerializer();
}
origin: oblac/jodd

/**
 * Serializes object into provided appendable.
 */
public void serialize(final Object source, final Appendable target) {
  JsonContext jsonContext = createJsonContext(target);
  jsonContext.serialize(source);
}
origin: oblac/jodd

/**
 * Resets JSON parser, so it can be reused.
 */
protected void reset() {
  this.ndx = 0;
  this.textLen = 0;
  this.path = new Path();
  if (useAltPaths) {
    path.altPath = new Path();
  }
  if (classMetadataName != null) {
    mapToBean = createMapToBean(classMetadataName);
  }
}
origin: oblac/jodd

/**
 * Defines custom {@link jodd.json.TypeJsonSerializer} for given type.
 */
public JsonSerializer withSerializer(final Class type, final TypeJsonSerializer typeJsonSerializer) {
  if (typeSerializersMap == null) {
    typeSerializersMap = new TypeJsonSerializerMap(TypeJsonSerializerMap.get());
  }
  typeSerializersMap.register(type, typeJsonSerializer);
  return this;
}
origin: oblac/jodd

private void breakLine(final JsonContext jsonContext) {
  jsonContext.write('\n');
  ident(jsonContext);
}
origin: oblac/jodd

/**
 * Writes open object sign.
 */
public void writeOpenObject() {
  popName();
  write('{');
}
origin: oblac/jodd

/**
 * Pop last element from the path.
 */
public CharSequence pop(){
  if (altPath != null) {
    altPath.pop();
  }
  return paths[--index];
}
origin: oblac/jodd

  @Override
  public boolean accept(final Path value, final PathQuery rule, final boolean include) {
    return rule.matches(value);
  }
};
origin: oblac/jodd

public LazyMap(final List keys, final List values, final boolean delayMap) {
  this.keys = array(Object.class, keys);
  this.values = array(Object.class, values);
  this.size = this.keys.length;
  this.delayMap = delayMap;
}
origin: oblac/jodd

private void ident(final JsonContext jsonContext) {
  for (int i = 0; i < deep; i++) {
    for (int j = 0; j < identSize; j++) {
      jsonContext.write(identChar);
    }
  }
}
origin: oblac/jodd

  @Override
  public Object get() {
    final int currentNdx = jsonParser.ndx;
    final Path currentPath = jsonParser.path;

    jsonParser.ndx = ndx;
    jsonParser.path = path;

    final Object object = jsonParser.parseObjectContent(targetType, keyType, componentType);

    jsonParser.ndx = currentNdx;
    jsonParser.path = currentPath;

    return object;
  }
}
origin: oblac/jodd

/**
 * Writes close array sign.
 */
public void writeCloseArray() {
  write(']');
}
origin: oblac/jodd

/**
 * Consumes char at current position. If char is different, throws the exception.
 */
protected void consume(final char c) {
  if (input[ndx] != c) {
    syntaxError("Invalid char: expected " + c);
  }
  ndx++;
}
origin: oblac/jodd

/**
 * Creates new instance of {@link jodd.json.MapToBean}.
 */
protected MapToBean createMapToBean(final String classMetadataName) {
  return new MapToBean(this, classMetadataName);
}
jodd.json

Most used classes

  • JsonParser
    Simple, developer-friendly JSON parser. It focuses on easy usage and type mappings. Uses Jodd's type
  • JsonSerializer
  • JsonObject
  • JsonContext
  • JSON
  • JsonArray,
  • JsonException,
  • JsonValueContext,
  • JsonWriter,
  • Path,
  • PathQuery,
  • PrettyJsonSerializer,
  • JsonAnnotationManager,
  • CatalogTest,
  • CircularDependencyTest$A,
  • CircularDependencyTest$B,
  • DataCreator,
  • JSON2,
  • JSONDeserializerTest$SimpleClassnameTransformer
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now