I get data from a JSON file of more than 3 lines and output it to a page via jsrender, but I ran into a problem, in the final objects, at the beginning of the properties, there is a "@" sign. Looks like that:

{ "@Code": "51.51.3", "@Name": "Оптовая торговля сырой нефтью", "@IsMain": "true" }, 

{{:Data.Report.OKOGU.@Name}} This code retrieves the data.

Error code:

 JsRender Error: Syntax error Compiled template code: // jsvTmpl var v,ret="" +"\n " +((v=data.Data@data.Name)!=null?v:"") +"\n\n\n "; return ret; : "illegal character" 

Via {{props}} {{>key}} {{>props}} displays the keys together with @. The point is these @ when compiling, how to get around it?

    1 answer 1

    The issue is resolved.

      var toStr = JSON.stringify(test); var toObj = jQuery.parseJSON(toStr.replace(/"@/g, '"')); 
    • And what if in the value, will be the necessary @ , and everything is removed from you, regardless of the keys or values? Yes, and it seems better to use JSON.parse from the box. - And
    • The solution is exclusively for jsrender and addressing the property of the object not through Obj['propetry'] , but through Obj.property . In my file there is no data starting with @ , for e-mails this regular expression is well suited. - Sindr0me