java - How can i create a custom Jackson Mapper? -


I want to make a data base for Google charts with Jackson that I can easily create a json file .. < / p>

I use this Jackson version:

  & lt; Dependency & gt; & Lt; Group & gt; Com.fasterxml.jackson.core & lt; / Group & gt; & Lt; ArtifactId & gt; Jackson-DataBind & lt; / ArtifactId> & Lt; Version & gt; 2.2.3 & lt; / Edition & gt; & Lt; / Dependencies & gt;   

I have the following classes (Example creates only rows at this time):

  Public class datatyll serializable {Private constant last long serialvarsian UID = 1 L ; @Jesenproperty ("lines") Private list & lt; DataTableRow & gt; dataTableRows; Public listing & lt; DataTableRow & gt; GetDataTableRows () {Data data layers; } Public Zero SatDATETableRo (list & gt; DataTableRow & gt; DataTables) {this.dataTableRows = dataTableRows; }}   

Then I have a datatyrere class

  Public class datatyable applies Serializable {Personal Static last long serial VERSIONUID = 1L; @Jesenproperty ("c") list & lt; Singletaselle & gt; singleTableCell; Public listing & lt; Singletaselle & gt; getSingleTableCell () {returnTeTableCell; } Public Zero SettingLabelel (list & gt; singletaselas & gt; singletablesel) {this .oneTableCell = singleTableCell; }}   

and there are several single tabs in one line

  serializable to apply the public class singletelecel {personal constant last long serialvarsian UID = 1 L; @Jasonproperty ("V") private value value; @Jasonproperty ("F") Private string formatted value = null; Public value getValue () {return value; } Public Zero Set Value (Value Value) {this.value = value; } Public string getFormattedValue () {return formattedValue; } Public Zero Set Formatted Values ​​(string formatted value) {this.formattedValue = formattedValue; }}   

This generates a Jason string for me:

{

  "rows": [{"c": ["V": {"value": "swan"}, "f": null}, {"v": {"value": 3.4}, "f": null}]}]   

}

The problem is my value object, it's an abstract class, I do not want this class being rendered as a Jason object, I just want to add a significant value! Therefore, it should not present it to:

"v": {"value": "swan"}

I just want it: "v": "swan"

And I want to be able to define that the value object can render the value object as a string, double or date object for example ... If this date is an object, then the date string is such that Must be replaced: "v": date (201010/10)

And if it is another object like a string or double , Then I have to decide how Jason String looks ..

my abstract class looks like this:

  public abstract class values ​​{} public class StringValue value Extension of {string value; } Public Square DoubleValue Expansion of Value {Double Price; } Increases the value of the public class date {date value; }   

I can make the following changes to your code so that you can achieve:

  Public intangible class values ​​{} increases public value StringValue {@JsonValue // do whatever you need, although I can not really see what string value will be; } Public Square DoubleValue Price Expansion {@JsonValue // Please do whatever you want, although I can not really see what the double value would be; } Public squared price increases price {@JsonValue @ datedformat () // date date code date here; }   

With the code you posted, I can not really see what the purpose of class Value is, but I ran away from here because I guess I am posting that you have done this with

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -