这是关于我在从 Tally Prime 以 JSON 格式导出报告以使用 JSON 进行集成时遇到的问题。
我们需要按照以下格式/示例发送 HTTP POST 请求:
[ { "customerCode":"Asc871", "customerName":"asxcshwha", "currencyCode": "IDR", "longestDay": 13, "month": 7, "noteInfo": "222222", "overduePayment": 20, "paymentTerm": 5, "receivableBalance": 35, "sameMonthAmount": 10, "sameMonthPayment": 10, "sameYearIncome": 10, "thanNinetyOverdueAmount": 10, "thanSixtyOverdueAmount": 10, "thanThirtyOverdueAmount": 10, "year": 2022, "yearYtdPayment": 10 } ]
HTTP POST 请求格式
但是,从 Tally Prime 生成 JSON 数据时,其导出如下:
{ "": [ { "batchId": "00000", "customerCode": "Customer A", "customerName": "Customer A", "currencyCode": "QAR", "year": "2024", "month": "7", "receivableBalance": "355.00", "overduePayment": "0", "paymentTerm": "30 Days", "thanNinetyOverdueAmount": "355.00", "yearYtdPayment": "0", "sameYearIncome": "0" }, { "batchId": "00000", "customerCode": "Customer B", "customerName": "Customer B", "currencyCode": "QAR", "year": "2024", "month": "7", "receivableBalance": "320.00", "overduePayment": "0", "paymentTerm": "0", "thanNinetyOverdueAmount": "320.00", "yearYtdPayment": "0", "sameYearIncome": "0" }, { "batchId": "00000", "customerCode": "Customer C", "customerName": "Customer C", "currencyCode": "QAR", "year": "2024", "month": "7", "receivableBalance": "60.00", "overduePayment": "0", "paymentTerm": "0", "thanNinetyOverdueAmount": "60.00", "yearYtdPayment": "0", "sameYearIncome": "0" } ] }
您可以注意到上例中 JSON 数据开头的额外标签(带花括号)({ "":) 与所需的格式进行比较。即,JSON 数据格式需要以方括号开头,而它是以花括号(大括号)开头。 有人可以指导我如何删除 Tally 生成的 JSON 数据中的那些额外标签吗?
下面是 TDL 代码,用于了解 JSON 报告在 Tally 中构建的方式:
`[Report : ReportBasedExportInJSONFormatTestRep]
Form : UDDahuaIntegUpldAcctRcvbleJSONRep
[Form : UDDahuaIntegUpldAcctRcvbleJSONRep]
Part : UDDahuaIntegUpldAcctRcvbleJSONRepBody
JSONTag : ""
[Part : UDDahuaIntegUpldAcctRcvbleJSONRepBody]
Line : UDDahuaIntegUpldAcctRcvbleJSONRepBody
Repeat : UDDahuaIntegUpldAcctRcvbleJSONRepBody : UDDahuaIntegAcctRcvbleRepUpldColl
Scroll : Vertical
[Line : UDDahuaIntegUpldAcctRcvbleJSONRepBody]
Line : UDDahuaIntegUpldRcvbleOSJSONRepBatchId
JSONTag : ""
[Line : UDDahuaIntegUpldRcvbleOSJSONRepBatchId]
Field : Simple Field
Local : Field : Simple Field : JSONTag : "batchId"
Local : Field : Simple Field : Set as : "0000"`
正如我在评论计数中提到的,TDL 不支持列表标签作为根标签 你可以参考this意味着你无法使用TDL读取或写入列表Json
由于您无法更改服务器 API 结构 您可以使用任何其他语言作为计数和服务器之间的中介
说 C#: 使用XML API,您可以从tally获取数据并根据服务器格式使用C#进行转换并将数据发布到服务器