P
P
Pavel2019-04-28 00:50:38
JavaScript
Pavel, 2019-04-28 00:50:38

How to replace characters in Json using JS?

Good day. The problem is that when I make a request to the database in JS, I get data like this:

[
  {
    "min": "845",
    "name": "Артист",
  } ,
 {
    "min": "234",
    "name": "Директор",
  }
}

As you can see, the "min" key value has a quoted string representation ( "845" ). I wanted the value to be without quotes ( "min": 845 ). How can I do that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2019-04-28
@ppyl

Store numbers in the database , not strings.
PS In JavaScript, you can convert in many ways. For example, like this:

arr[0].min -= 0;
arr[1].min -= 0;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question