标题翻译
Take non-nested JSON String and Build Json Nested String
问题
这对我来说很新。我正在从Cassandra表中读取数据。这些数据是通过"select json * ..."查询提取的,但问题在于,该JSON的格式为:
{"acct_ref_nb": 1401040701, "txn_pst_dt": "2020-02-26", "txn_pst_tm": 1934131, "txn_am": 15000.0, ...
每个字段都用引号括起来,后面跟着冒号,然后是值,再加上逗号和下一个字段,依此类推。
我们需要重新格式化它,并创建一个嵌套结构。我们还需要更改字段的名称。因此,您可能会得到类似于以下的内容:
"{
"ccEvent": {
"account": {
"accountReferenceNumber": 1401040701,
"transactionPostDate": "2020-02-26",
"transactionPostTime": 1934131,
"transactionAmount": 15000.0,
........
是否有首选的库可以实现这一点?即使在高层次上,我都对如何做这个感到完全迷茫。谢谢。
英文翻译
This is very new to me. I am reading data from a cassandra table. This data is being extracted via a "select json * ..." query but here's the thing. The format of that json is
{"acct_ref_nb": 1401040701, "txn_pst_dt": "2020-02-26", "txn_pst_tm": 1934131, "txn_am": 15000.0 ....
Every field is in quotation marks, followed by a colon, followed by the value, then a comma and the next field, so on and so forth.
We need to reformat this and have a nested structure. We also need to change the names of the fields. So you would have something like...
"{
"ccEvent": {
"account": {
"accountReferenceNumber": 1401040701,
"transactionPostDate": "2020-02-26",
"transactionPostTime": 1934131,
"transactionAmount": 15000.0,
........
Is there a preferred library to do this? I'm literally lost even at a high level on how to do this. Thanks.
专注分享java语言的经验与见解,让所有开发者获益!
评论