Skip to content

Latest commit

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

keyparse

This project allows custom JSON key syntax

  • KeyParse does not recursively search nested objects.
  • Non-compliant keys are ignored by the KeyParse layer.

Syntax

{
"key:[attr1:val1,attr2:val2]": "value"
}

Usage

Basic Usage

Deserialize the JSON normally with Jackson:

ObjectMappermapper = newObjectMapper();
ObjectNoderoot =
(ObjectNode) mapper.readTree(json);
//Create a reader for the current object:JacksonJsonKeyReaderreader =
JacksonJsonKeyReader.of(root);
//Then request attributes for a logical key:Optional<Map<String, String>> attributes =
reader.attributes("product");

For:

{
"product:[type:card,id:123]": "GD01-001"
}
attributes.ifPresent(attrs -> { Stringtype = attrs.get("type");
Stringid = attrs.get("id");
System.out.println(type);
System.out.println(id); });

the returned attributes are:

type = card id = 123

About

add capability to json parsing

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages