SAP ABAP 将长 JSON 字符串写为变量或无大格式的文字

问题描述 投票:0回答:0

是否有可能在 ABAP 中将长 JSON 数据作为字符串文字写入,而无需对字符串进行大量换行或格式化?例如,我可以将字符串包含在某种字符串模板中吗?或者在 ABAP 的某处是否存在类似 JSON.stringify(..) 的方法?或者它可以与包含一起使用?我不知道,我对 ABAP 还是很陌生......

例如这个数据:

{"todos":[{"id":1,"todo":"Do something nice for someone I care about","completed":true,"userId":26},{"id":2,"todo":"Memorize the fifty states and their capitals","completed":false,"userId":48},{"id":3,"todo":"Watch a classic movie","completed":false,"userId":4},{"id":4,"todo":"Contribute code or a monetary donation to an open-source software project","completed":false,"userId":48},{"id":5,"todo":"Solve a Rubik's cube","completed":false,"userId":31},{"id":6,"todo":"Bake pastries for me and neighbor","completed":false,"userId":39},{"id":7,"todo":"Go see a Broadway production","completed":false,"userId":32},{"id":8,"todo":"Write a thank you letter to an influential person in my life","completed":true,"userId":13},{"id":9,"todo":"Invite some friends over for a game night","completed":false,"userId":47},{"id":10,"todo":"Have a football scrimmage with some friends","completed":false,"userId":19},{"id":11,"todo":"Text a friend I haven't talked to in a long time","completed":false,"userId":39},{"id":12,"todo":"Organize pantry","completed":true,"userId":39},{"id":13,"todo":"Buy a new house decoration","completed":false,"userId":16},{"id":14,"todo":"Plan a vacation I've always wanted to take","completed":false,"userId":28},{"id":15,"todo":"Clean out car","completed":false,"userId":33},{"id":16,"todo":"Draw and color a Mandala","completed":true,"userId":24},{"id":17,"todo":"Create a cookbook with favorite recipes","completed":false,"userId":1},{"id":18,"todo":"Bake a pie with some friends","completed":false,"userId":1},{"id":19,"todo":"Create a compost pile","completed":true,"userId":5}]}

如果在 ABAP 中存在类似模板字符串文字的东西,如 `` 在 javascript 中,然后您可以在其中包含 ' 和 " 而无需转义字符,那将是理想的事情...

顺便说一句...我想将 JSON 反序列化到一个内部表中,然后使用一个似乎已经有效的循环将其插入到我的字典表中,

DATA: lv_json TYPE string VALUE '[{"id":10,"todo": ...}]'

我只是还不知道如何找到一种好的格式来解析 JSON...(是否还存在从文件中解析 json 的程序?)..

javascript json serialization abap sap
© www.soinside.com 2019 - 2024. All rights reserved.