Giter Site home page Giter Site logo

java-luxem's Introduction

luxem

A library for reading and writing luxem in Java.

Maven

<dependency>
    <groupId>com.zarbosoft</groupId>
    <artifactId>luxem</artifactId>
    <version>0.0.1</version>
</dependency>

Basic use cases

1. Read a document with no known type

System.out.format(
	"%s\n",
	 ((Map)Luxem.parse("[a, {b: c}]").get(1)).get("b")
);

2. Read a document into a list of annotated types

@Configuration
public class MyType {
	@Configuration
	public int a;
}

System.out.format(
	"%s\n",
	 Luxem.parse(new Reflections(), new TypeInfo(MyType.class), "{a: 4},").get(0).a
);

Output

4

3. Write a document from an annotated type

@Configuration
public class MyType {
	@Configuration
	public int a;
}

MyType x = new MyType();
x.a = 4;
Luxem.write(x, System.out);

Output

{a:4,},

If you have multiple root elements, use TypeWriter and call write for each element.

4. Write a document manually

RawWriter writer = new RawWriter(System.out);
writer.recordBegin();
writer.key("a");
writer.primitive("4");
writer.recordEnd();

Output

{a:4,},

Other features

  • Deserialize to an event stream for use with pidgoon
  • Pretty print (indent)
  • Write a tree of Map, List, Typed, and toStringable objects (reverse of example 1) with TreeWriter
  • Tokenize luxem RawReader

See the Javadoc (not hosted currently) for details.

java-luxem's People

Contributors

rendaw avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.