Giter VIP home page Giter VIP logo

jackson-dataformat-hocon's People

Contributors

chonton avatar chonton-elementum avatar friso avatar jclawson avatar tburch avatar valery1707 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jackson-dataformat-hocon's Issues

Pom changes as part of PR10

It was not my intent to include the pom change that changed the maven coordinates in PR10. You probably want to restore the following sections:

<groupId>com.jasonclawson</groupId>
<artifactId>jackson-dataformat-hocon</artifactId>

and

<url>https://github.com/jclawson/jackson-dataformat-hocon</url>

and

<scm>
  <connection>scm:git:https://github.com/jclawson/jackson-dataformat-hocon.git</connection>
  <developerConnection>scm:git:https://github.com/jclawson/jackson-dataformat-hocon.git</developerConnection>
  <url>https://github.com/jclawson/jackson-dataformat-hocon/</url>
</scm>

and

<issueManagement>
  <system>github</system>
  <url>https://github.com/jclawson/jackson-dataformat-hocon/issues</url>
</issueManagement>

Convert dash case to camel case

When parsing HOCON, the mapper does not recognize dash case (e.g. 'sample-key: "a"') to convert it to camel case ('sampleKey')

PS: Sorry for the previous title. My co-worker was messing with my computer.

cannot include yaml file

If I have a .conf file:

{ a : { include required(classpath("myyaml")) } }

I will get a stack-trace with:

Caused by: java.io.IOException: resource not found on classpath: myyaml.conf
	at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:735)
	at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:710)
	at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:180)
	... 47 more

and if I give a suffix:

{ a : { include required(classpath("myyaml.yaml")) } }

I will get:

Caused by: java.io.IOException: resource not found on classpath: myyaml.yaml.conf
	at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:735)
	at com.typesafe.config.impl.Parseable$ParseableResources.rawParseValue(Parseable.java:710)
	at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:180)
	... 47 more

Seems this is not supported? But from the github readme I see:

In short, HOCON combines YAML, JSON, and Properties files into a single format. On most cases, YAML, JSON, and Properties formats are all valid HOCON--- and it can be mixed and matched at will. Check out the HOCON docs for more detail on the format.

Transforming from HOCON to JSON before deserialization

Hello.

For deserialization, is there an advantage in using jackson-dataformat-hocon over transforming the HOCON configuration to JSON for Jackson's reading? Is jackson-dataformat-hocon more intended for serialization?

Sample code: String json = typesafeConfig.root().render(ConfigRenderOptions.concise());

Thanks!

Cannot parse map if the map contains 0

val parsedMap = Constants.HOCON_MAPPER.readValue<Map<Int, String>>("""{ 1 = "abc" }""")
println(parsedMap)

Output: {1=abc}

val parsedMap = Constants.HOCON_MAPPER.readValue<Map<Int, String>>("""{ 0 = "abc" }""")
println(parsedMap)

Output:

Exception in thread "main" com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.LinkedHashMap` out of START_ARRAY token
 at [Source: UNKNOWN; line: -1, column: -1]
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
	at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1343)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1139)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1093)
	at com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromEmpty(StdDeserializer.java:600)
	at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:360)
	at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:29)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3023)
	at net.perfectdreams.loritta.QuirkyStuffKt.main(QuirkyStuff.kt:63)
	at net.perfectdreams.loritta.QuirkyStuffKt.main(QuirkyStuff.kt)

This happens even if the Map is another type (Example: Map<String, String>)

This does NOT happen when parsing with lightbend/config:

val conf = ConfigFactory.parseString("""{ 0 = "abc" }""")
println(conf)

Output: Config(SimpleConfigObject({"0":"abc"}))

Implement HoconTreeTraversingParser#getTokenLocation using ConfigOrigin

Currently calling getTokenLocation() on a HoconTreeTraversingParser object returns JsonLocation.NA, which is more or less valid, as there is no JSON location as the input isn't JSON.

Yet for some use cases it does make sense to have access to a location and even the underlying ConfigOrigin object. Since the parser has access to this, it would be possible to implement getTokenLocation() by returning a subclass of JsonLocation that fills the line number field and source object (which are the only things available from ConfigOrigin) and provide access to the underlying ConfigOrigin.

A concrete use case for this is implementing a custom deserializer for Duration objects using the same code that TypeSafe Config uses for parsing the duration. This requires a ConfigOrigin. The custom deserialier could attempt to cast the JsonLocation to our own subclass and have access to the origin that way.

I'd be happy to provide a PR that implements this if it is a good idea.

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.