Hongmu Notes

🔗 Concatenate arrays into strings

Concatenate the JSON array into a line of text using custom connectors.

Concatenate arrays into strings

Instructions for use

  • Paste the JSON array, fill in the connectors and click "Splice"
  • If you add a backslash and n in the connector, it will become a real line break.
  • Array elements must be wrapped in double quotes. Single quotes will fail to parse.

Array to string

When the array in the code is to be turned into a line of display copy, it is most likely to make mistakes by manually adding quotation marks and deleting commas. Leave it to the tool to spell it out in one go.

📌 Do arrays have to be written as JSON?

Yes. This page is parsed according to JSON rules, so elements must use double quotes and commas must use English half-width; this is also compatible with numeric and special character elements.

📌 Splicing rules

The tool first uses JSON parsing to read the input into an array, and then uses the connector you fill in to connect the elements in sequence: leave the connector blank to connect directly, fill in ordinary symbols and insert them one by one. When a backslash plus n appears in the connector, it will be replaced with a real newline before participating in the connection. If the parsing fails, the result box will display a parsing error message, the status line will prompt a format problem, and the input content will remain unchanged; when the array is empty, the result will be an empty string, and the status line will still prompt that 0 elements have been spliced.

🧭 Common uses

It is very common to assemble the string array returned by the interface into display copy, the label array into a line of labels, the field name array into a SQL field list, and convert the array in the code into a string connected with commas or vertical bars; when multiple lines of text are required, use newline as the connector.

All keywords and tutorials 12

❓ FAQ

Can you spell an array of numbers?
Can. Numeric elements will be parsed as numbers and then concatenated.
Can the operation be reversed?
Can. To convert a line of text to an array, please use the string to array tool on the site.
Common scenarios for converting arrays to strings
The tag array is assembled into display copy, and the field array is assembled into a list.