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

How to convert string into json object in vue

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

Share

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

This article mainly introduces the relevant knowledge of how to convert string into json objects in vue, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will have something to gain after reading this article on how to convert string into json objects in vue. Let's take a look.

The method of converting string into json object in vue: 1, using eval, the syntax is "result = eval ('('jsonstr')');"; 2, using "JSON.parse ()", the syntax is "result = JSON.parse (jsonstr);".

This article operating environment: windows10 system, Vue2.9.6 version, DELL G3 computer.

How to convert string into json object in vue

Convert Json strings to json objects

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 article on "how to convert string into json objects in vue". Thank you for reading! I believe you all have a certain understanding of "how to convert string into json objects in vue". If you want to learn more, you are welcome to follow the industry information channel.

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