Remove all strings before keys via javascript

Asked

Viewed 61 times

0

I have a css file and I would like to generate a JSON, for this, the first step I found would be to remove the entire selector before the brackets

.meuSeletor {
  propriedade: valor;
}

for

{
  propriedade: valor;
}

But I have no idea how to do, I couldn’t think of any regex, nor an algorithm to select and remove this text.

As I have all selectors in one file, it complicates a little more Example:

*, *:before, *:after {
  box-sizing: border-box;
}

html {
  overflow-y: scroll;
}

body {
  background: #c1bdba;
  font-family: 'Titillium Web', sans-serif;
}

a {
  text-decoration: none;
  color: #1ab188;
  -webkit-transition: .5s ease;
  transition: .5s ease;
}

Does anyone have any idea?

  • I don’t think it will work to create a JSON because of the values of the properties. They would have to be in quotes, otherwise it will fail. For example, this background: #c1bdba; would have to stay background: "#c1bdba;".

  • 1

    What is the idea of this JSON? You can explain the problem you are trying to solve?

  • 1

    Tries this site. Or use that library

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.