【问题标题】:How do I use json data as my input?如何使用 json 数据作为输入?
【发布时间】:2016-04-20 07:40:32
【问题描述】:
`public class VatCalculator {

    Product product=new Product();
    Airport airport=new Airport();
    VATRates vatrates =new VATRates();
    TaxTable taxtable= new TaxTable();

    //private String vatTable;

   // public VatCalculator(TaxTable taxTable) {
    //    `Z`super(taxTable);
    //    this.vatTable= generateVatTable();
   // }

我需要在我的增值税计算器类中使用税表作为输入。我创建了一个对象,但不确定如何从 TaxTable 获取数据。我怎样才能做到这一点?

I am trying to create a Vat Calculator which calculates based on the taxtable.[vat class][1]
[data][2]


  [1]: http://i.stack.imgur.com/r5MFs.png
  [2]: http://i.stack.imgur.com/Ajj42.png

有一个名为 TaxTable 的类,用于保存 JSON 文件 (DB) 中的数据。 图片:

public class TaxTable implements Serializable {
private static final long serialVersionUID = 1L;
private String taxGroup;
private double onboardSalePct;
private double onboardServicePct;
private double preorderSalePct;
private double preorderServicePct;

@JsonCreator
public TaxTable(@JsonProperty("tax_group") String taxGroup,
                @JsonProperty("onboard_sale_pct") double onboardSalePct,
                @JsonProperty("onboard_service_pct") double onboardServicePct,
                @JsonProperty("preorder_sale_pct") double preorderSalePct,
                @JsonProperty("preorder_service_pct") double preorderServicePct) {
    this.taxGroup = taxGroup;
    this.onboardSalePct = onboardSalePct;
    this.onboardServicePct = onboardServicePct;
    this.preorderSalePct = preorderSalePct;
    this.preorderServicePct = preorderServicePct;
 }


/**
  * @return the taxGroup
  */
 public String getTaxGroup() {
     return taxGroup;
 }

 /**
  * @param taxGroup
  *            the taxGroup to set
  */
 public void setTaxGroup(String taxGroup) {
     this.taxGroup = taxGroup;
 }

【问题讨论】:

  • 您使用的是哪种语言?
  • 看起来像Java或者至少代码包含一个super()关键字。
  • 请不要通过将代码隐藏在外部链接后面的图片中来分割您的问题,使用提供的代码标签将它们嵌入到您的问题中;这可能会吸引更多愿意回答的人。
  • 将进行更改。我正在使用 Java。

标签: java json parsing input


【解决方案1】:

您是否打算将 Java 对象转换为 JSON 并将其存储为字符串。

您可以为此目的使用以下库。

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 2016-09-29
    • 1970-01-01
    • 1970-01-01
    • 2017-11-06
    • 2020-09-22
    • 2019-02-13
    • 1970-01-01
    • 1970-01-01
    • 2020-04-21
    相关资源
    最近更新 更多