How to deal with this kind of data returned by the backend?

the backend uses C-sharp. The data returned to the front end is shown in the figure below. How to convert it to JSON? Should this situation be handled at the back end or at the front end?

Mar.14,2022

use the rule to get the JSON string in the tag first

/[^><]+(?=<\/string>)/img

then convert to JSON

JSON.parse()

xml with json, inside had better let the backend peel off the outer layer


you treat xml as html, and xml can also use DOM api

such as JQ

var str = $(data).find('string').html()

//xml
var str = $( $.parseXML( data ) ).find('string').html()

Thank you all!

the answer found on the Internet has been successfully converted to JSON.

function success(result){
    if(typeof(result) == "object"){
        result = result.lastChild.firstChild.nodeValue;//xml
        eval("result = "+result);//json
    }
}
Menu