当前位置:网站首页>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)
边栏推荐
- Mysql 45讲学习笔记(十)force index
- The sorting in C language realizes the number sorting method from small to large
- 校园网络问题
- Industrial computer anti-virus
- Chapter 1 programming problems
- [FPGA tutorial case 7] design and implementation of counter based on Verilog
- Selection (021) - what is the output of the following code?
- What is the sheji principle?
- Crawler (III) crawling house prices in Tianjin
- What is the use of cloud redis? How to use cloud redis?
猜你喜欢
The most effective futures trend strategy: futures reverse merchandising
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
Wechat applet scroll view component scrollable view area
【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)
Selenium driver ie common problem solving message: currently focused window has been closed
selenium IDE插件下载安装使用教程
Cervical vertebra, beriberi
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
The important role of host reinforcement concept in medical industry
A new understanding of how to encrypt industrial computers: host reinforcement application
随机推荐
How can the old version of commonly used SQL be migrated to the new version?
Analysis of tars source code 1
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
centos8安装mysql.7 无法开机启动
What is tweeman's law?
Redis面试题集
由于dms升级为了新版,我之前的sql在老版本的dms中,这种情况下,如何找回我之前的sql呢?
Mysql 45讲学习笔记(十)force index
Mysql 45讲学习笔记(七)行锁
Tar source code analysis Part 7
Mysql 45讲学习笔记(十一)字符串字段怎么加索引
测试用例的设计
Code rant: from hard coding to configurable, rule engine, low code DSL complexity clock
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
Mysql 45讲学习笔记(十四)count(*)
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
2022年,或許是未來10年經濟最好的一年,2022年你畢業了嗎?畢業後是怎麼計劃的?
Mysql 45讲学习笔记(六)全局锁
How does the recv of TCP socket receive messages of specified length?
Explain in one sentence what social proof is