search

Home  >  Q&A  >  body text

javascript - Can data in json format be converted into a normal string

I use json.stringify() to get the data when submitting the form. Return as follows.
{"domains":[{"value":"vvvvvvvvv"}],"cona":"heeheeheeheeheeheeheexia","conb":"minutes, points, points, points v"}

Can it be converted into a normal string format? I want to convert it into the following format. I have tried many methods without success.

怪我咯怪我咯2788 days ago588

reply all(2)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-18 11:00:08

    Just extract the following content and splice it together

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-18 11:00:08

    json is essentially a string, but it is a "formatted" string.
    If you want to convert it to other strings, you need to write your own rules, such as:

    var objFormat = {toString:function(){return this.domains.map(function(item){
    return item.value;
    }).join(',')+','+this.cona+','+this.conb}};
    var jsonStr   = '{"domains":[{"value":"vvvvvvvvv"}],"cona":"嘻嘻嘻嘻嘻嘻下","conb":"分分分分分分v"}';
    var parsedString = objFormat.toString.call(JSON.parse(jsonStr));
    // 得到 vvvvvvvvv,嘻嘻嘻嘻嘻嘻下,分分分分分分v

    reply
    0
  • Cancelreply