Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of transferring json to string by vue?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the method of vue converting json to string". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Vue will json to string method: 1, open the corresponding js code; 2, through the "arr.join (',');" method to concatenate the array items into strings.

This article operating environment: Windows7 system, Vue2.9.6, Dell G3 computer.

How does vue convert json to string?

Vue string to Json conversion:

one。 Conversion between string and array

1. Convert a string to an array

Str.split (','); / / A split string with a comma

2. Convert an array to a string

Arr.join (','); / / concatenate array items into strings, separated by commas

II. Convert Json string to json object

1. Use eval

Result = eval ('('+ jsonstr +')'); / / jsonstr is the json string

2. Use JSON.parse ()

Result = JSON.parse (jsonstr); / / jsonstr is a json string

The difference between eval and JSON.parse:

Eval is supported by javascript, and data can be converted without strict json format.

JSON.parse is a conversion method supported by browsers. You must have a standard json format to convert it.

This is the end of the introduction of "what is the method for vue to transfer json to string". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report