Coder Social home page Coder Social logo

Comments (7)

shizhengchao avatar shizhengchao commented on July 23, 2024

when i add maven fast json in my class path ,it cant work.

from druidry.

shizhengchao avatar shizhengchao commented on July 23, 2024

where is DruidResponse class of the example, and i replace it as JSONObject, it cant also work .

List<JSONObject> responses = client.query(query, JSONObject.class);

Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "timestamp" (class org.json.JSONObject), not marked as ignorable (0 known properties: ])
at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 16] (through reference chain: java.util.ArrayList[0]->org.json.JSONObject["timestamp"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:823)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1153)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1589)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1567)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:294)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:1574)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:965)
at org.glassfish.jersey.jackson.internal.jackson.jaxrs.base.ProviderBase.readFrom(ProviderBase.java:838)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:257)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:236)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:156)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1091)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:874)


from druidry.

shizhengchao avatar shizhengchao commented on July 23, 2024

if i add the maven in my class path,

<dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.58</version>
        </dependency>

i get the exception:

Caused by: com.alibaba.fastjson.JSONException: expect '[', but {, pos 1, line 1, column 2{"error":"Could not resolve type id 'TOPN' into a subtype of [simple type, class org.apache.druid.query.Query]: known type ids = [Query, dataSourceMetadata, groupBy, scan, search, segmentMetadata, select, timeBoundary, timeseries, topN]\n at [Source: HttpInputOverHTTP@77d8b899[c=778,q=0,[0]=null,s=STREAM]; line: 1, column: 745]"}
	at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:722)
	at com.alibaba.fastjson.serializer.CollectionCodec.deserialze(CollectionCodec.java:126)
	at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:689)
	at com.alibaba.fastjson.JSON.parseObject(JSON.java:378)
	at com.alibaba.fastjson.JSON.parseObject(JSON.java:443)
	at com.alibaba.fastjson.JSON.parseObject(JSON.java:551)
	at com.alibaba.fastjson.support.jaxrs.FastJsonProvider.readFrom(FastJsonProvider.java:413)
	... 16 more

from druidry.

abhi195 avatar abhi195 commented on July 23, 2024

Hi @shizhengchao
The DruidResponse that is shown in Readme example is not actual class implemented in Druidry. That's just example for showing how can you map the response of the query to an object. You have to write you own mapping Class based on which query you are doing and than use that Class to map to query response.

Or simply you can use String result = client.query(query);. Here result will be a valid JSON string and you can map this string to JSONObject and use it.

from druidry.

abhi-zapr avatar abhi-zapr commented on July 23, 2024

Hey @shizhengchao

Is your issue resolved ? Let us know and we will close the issue.

from druidry.

shizhengchao avatar shizhengchao commented on July 23, 2024

i found the reason of the issue :
because of the 'com.alibaba.fastjson', When serializing a class to json, the enum type defaults to output name。For example the when enum QueryType.TOPN serializing, it's TOPN, not topN。

from druidry.

shizhengchao avatar shizhengchao commented on July 23, 2024

Hey @shizhengchao

Is your issue resolved ? Let us know and we will close the issue.

yes, i resolved, thank you

from druidry.

Related Issues (20)

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.