无法在mysql表字段中存储完整的json字段

yptwkmov  于 2021-07-26  发布在  Java
关注(0)|答案(2)|浏览(360)

我在一个api响应中得到一个大的json数据。我正在尝试将这个json响应存储在本地mysql表中。但无法存储完整的json响应。请查找以下json信息。

api json响应示例:

{
    "responseCode": 200,
    "date": "2020-06-03",
    "message": "Success",
    "couponDetails": {
        "total": 14949,
        "codes": "35033769,35441136,35803675,34407176,34717909,34950692,35059148,35452352,35688911,35904465,35904658,35904753,35904824,35904942,35905306,35905318,35905434,35905673,35906615,35907029,35907154,35907222,35907345,35907592,35907683,35907951,35908161,35908194,35908206,34664348,34664436,34665057,34665072,34665768,34665950,34666051,34666110,34666879,34667228,34668101,34670133,34670162,34670259,34670661,34670687,34670994,34671179,34671296,34672207,34672276,34672631,34672747,34673619,34673709,34675355,34676588,34677690,34678019,34679260,34679468,34680550,34680694,34680838,34683321,34684752,34684796,34685198,34685826,34686220,34686276,34351922,34352193,34352369,34352553,34353629,34353971,34355064,34355541,34355625,34356802,34357668,34357869,34357922,34360451,34360500,34360764,34361049,34361174,34361315,34362337,34362412,34363370,34364187,34365025,34365188,34365415,34365904,34366777,34366877,34367361,34368025,34368078,35542974,35543013,35543084,35268238,35268397,35268774,35269689,35269933,35270038,35250597,35063719,35064231,35064237,35270577,35270705,35270969,35064514,35064963,35065129,35251645,35251660,35251798,35253022,35253300,35272389,35272446,35272519,35272640,35272641,35273596,35273716,35423127,35423184,35423372,35424244,35425607,35485524,35486647,35486711,35486970,35487111,35470199,35470485,35488099,35488145,35488270,35490204,35534378,35535484,35535520,35535559,35535601,35535818,21979363,21508096,26237385,24734847,22263784,26889428,29292212,20415646,21836743,20300178,21831783,21198543,23739734,29773862,20715551,25488915,28894112,26536357,26695866,27133857,29133336,28763373,21850298,21990790,27757421,2421785723"
    }
}

在我的本地数据库表中,我只能插入以下信息,但不完整:

{
    "responseCode": 200,
    "date": "2020-06-03",
    "message": "Success",
    "couponDetails": {
        "total": 14949,
        "codes": "35033769,35441136,35803675,34407176,34717909,34950692,35059148,35452352,35688911,35904465,35904658,35904753,35904824,35904942,35905306,

mysql表结构:

CREATE TABLE `bookdata_codeinfo_history` (
  `generated_date` date DEFAULT NULL,
  `book_code` longtext,
  `service` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

我想把json存储在“book\u code”字段中,但存储的信息很少。我使用的是mysql-5.7.13版本。请告诉我如何解决这个问题

zpgglvta

zpgglvta1#

我认为,与其尝试将图书代码存储为字符串,不如将图书代码字符串分解为单独的行来对表进行建模。
这将有助于搜索数据和数据模型的未来扩展性。

yhxst69z

yhxst69z2#

真奇怪,一个长文本最多可以支持4294967295字节~4gb(请重新检查您的table结构)。
或者
将这些json放在文件中,并将路径保存在数据库中
或者
将“代码”字段拆分为多行,例如idrequest、code,并且每个代码都包含一个值

相关问题