当前位置:网站首页>Splicing plain text into JSON strings - easy language method
Splicing plain text into JSON strings - easy language method
2022-07-04 06:56:00 【Teng Qingshan】
demand :
Zhang San
Li Si
Wang Wu
Turn such plain text into the following json, It is possible to use any programming language to splice and generate , Put code that is easy to implement in language
{"data":[{"name":" Zhang San "},{"name":" Li Si "},{"name":" Wang Wu "}]}
Code :
. edition 2
. support library spec
. Subroutines Subroutines _ Plain text to json, The text type , , name
. Parameters text, The text type
. local variable arr, The text type , , "0"
. local variable i, Integer type
. local variable line_text, The text type
. local variable result, The text type
arr = Split text (text, # A newline , )
result = “{” + # quotes + “data” + # quotes + “:[”
. Cycle head ( Take the number of array members (arr), i)
line_text = arr [i]
Debug output (line_text)
result = result + “{” + # quotes + “name” + # quotes + “:” + # quotes + line_text + # quotes + “}”
. If it's true ( Take the number of array members (arr) ≠ i)
result = result + “,”
. If it really ends
. Cycle end ()
result = result + “]}”
return (result)

边栏推荐
- Introduction to spark core components
- 抽奖系统测试报告
- MySQL 45 lecture learning notes (x) force index
- Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
- js 常用时间处理函数
- tars源码分析之8
- [network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA
- uniapp 自定義環境變量
- the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
- Mysql 45讲学习笔记(十二)MySQL会“抖”一下
猜你喜欢

Common usage of time library

响应式——媒体查询

校园网络问题

Uniapp custom environment variables

MySQL relearn 2- Alibaba cloud server CentOS installation mysql8.0

Review of enterprise security incidents: how can enterprises do a good job in preventing source code leakage?

Uniapp applet subcontracting

centos8安装mysql.7 无法开机启动

Selenium driver ie common problem solving message: currently focused window has been closed

leetcode 310. Minimum Height Trees
随机推荐
在已经知道表格列勾选一个显示一列
leetcode825. 适龄的朋友
About how idea sets up shortcut key sets
2022, peut - être la meilleure année économique de la prochaine décennie, avez - vous obtenu votre diplôme en 2022? Comment est - ce prévu après la remise des diplômes?
[Valentine's day] - you can change your love and write down your lover's name
Tar source code analysis 9
tars源码分析之9
Selection (023) - what are the three stages of event propagation?
请问旧版的的常用SQL怎么迁移到新版本里来?
抽奖系统测试报告
2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
响应式移动Web测试题
CORS is not intended to protect API endpoints - nikofischer
校园网络问题
[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph
MySQL 45 learning notes (XI) how to index string fields
Modify TCP timestamp to optimize transmission performance
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
Mysql 45讲学习笔记(十)force index