当前位置:网站首页>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)

边栏推荐
- tars源码分析之10
- How to input single quotation marks and double quotation marks in latex?
- Tar source code analysis 4
- MySQL 45 lecture learning notes (x) force index
- tars源码分析之7
- Set JTAG fuc invalid to normal IO port
- Another company raised the price of SAIC Roewe new energy products from March 1
- 【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)
- MySQL 45 lecture learning notes (XIII) delete half of the table data, and the table file size remains the same
- Mysql 45讲学习笔记(十二)MySQL会“抖”一下
猜你喜欢

Uniapp applet subcontracting

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

【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真

关于IDEA如何设置快捷键集

selenium驱动IE常见问题解决Message: Currently focused window has been closed.

notepad++如何统计单词数量

The most effective futures trend strategy: futures reverse merchandising

com. alibaba. nacos. api. exception. NacosException

P26-P34 third_ template

regular expression
随机推荐
Fundamentals of SQL database operation
Analysis of tars source code 5
[FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
[FPGA tutorial case 7] design and implementation of counter based on Verilog
tars源码分析之5
js 常用时间处理函数
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
Option (024) - do all objects have prototypes?
Tar source code analysis 6
[problem record] 03 connect to MySQL database prompt: 1040 too many connections
What is the "relative dilemma" in cognitive fallacy?
校园网络问题
selenium IDE插件下载安装使用教程
2022 is probably the best year for the economy in the next 10 years. Did you graduate in 2022? What is the plan after graduation?
Tar source code analysis Part 3
Campus network problems
抽奖系统测试报告
云Redis 有什么用? 云redis怎么用?
MySQL 45 lecture learning notes (XIV) count (*)
What is tweeman's law?