Golang gin securejson

How to use securejson response in angular.

It is adding while(1); before response.

I have to parse or any other method.

Please guide me

please help me . how to use securejson in angular

  • Secure JSON transmission typically involves HTTPS, which encrypts data between the client (your Angular application) and the server. This protects the data from being intercepted and tampered with.

I am getting response like this

        "companycode": 1,
        "Name": "demo",
        "Add1": "add1",
        "Add2": "",
        "Add3": "",
        "Website": "",
        "Logopath": ""

From the docs:

Using SecureJSON to prevent json hijacking. Default prepends “while(1),” to response body if the given struct is array values.

So it’s behaving exactly how it should. I’m not sure what prepending that to your JSON will do to prevent hijacking and I guess I’m not alone:

Whatever security you think the JSON prefix is affording you, I’ve never understood a single purpose for it; as evidenced by the fact that you simply strip it off anyway. No one has ever been able to articulate a single actual benifit or reason for the JSON prefix. So far as I can tell, it’s just some thing Adobe did years ago for “reasons” and everyone went along with it because it had “something to do with security”.

But - it seems you are getting the exact result you should expect given what the docs say.

How to parse in angular or how to remove in angular

There should be something in angular or other languages. It should understand this tag. While(1)

Thanks Everyone .

It is working for me now .

I have added this line

( server.SecureJsonPrefix(")]}',\n") )

if we don’t mention , default it is taking while(1) and angular can’t parse this json.