K
K
krumza2017-03-12 15:58:55
JavaScript
krumza, 2017-03-12 15:58:55

How to parse an associative array using only JS?

I am redesigning a website from php on a node and faced with the complexity of the old database architecture.
I have a simple site - template engine - ejs.
There are materials on the site (several thousand), each material has tags that are in this structure:
the code in the template :
<%- JSON.stringify(item.tags) %>
returns such a bug:
"tags":"a:2:{i:0;s:4:\"тег1\";i:1;s:5:\" тег2\";}"
Here is the question - how to parse this object using JS?
in principle, there is a way to solve it - through regular expressions - rub, clean, etc., but maybe there is something else?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xutesayor, 2017-03-12
@krumza

It's easier to parse using php and save it to the database as json.
Just two commands will be: json_encode(unserialize($val))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question