Spring Boot + REST + Spring Security: how to generate a custom JSON response for HTTP 403

I have a Spring-Boot REST controller, protected by Spring-Security. It works fine. If the client sends an HTTP request without having the proper access token on the HTTP header then he gets back an HTTP 403 response, as I expect. curl -i localhost:8301/user/11: HTTP/1.1 403 X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Cache-Control: no-cache, no-store, max-age=0, must-revalidate…

How can i parse json object containing slashes in java

I want to parse a windows path in java. this is part of the json: …”sslkey”:”c:\usr\ssl\key.jks” and this is the code: JsonObject jsonargs = gson.fromJson(args[0], JsonObject.class); SSLKEY = jsonargs.get(“sslkey”).getAsString(); I tried with \ also in the value, but the error that I have is: Exception in thread “main” com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1…

Ruby: validate JSON with openapi

I have HTTP request payload structured according to jsonapi.org guidelines: { “data”: { “type”: “employee”, “attributes”: { “firstName”: “John”, “lastName”: “Doe”, } } } then I have OpenApi specification (yaml) of this payload: employee: type: object required: [data] properties: data: type: object properties: type: type: string enum: [employee] attributes: type: object required: [firstName, lastName] properties:…

Android App Making JSON Call Gets Unexpected Data From Server, But Same Call Works In Browser

I have an Android app that makes a server call which returns JSON. The server code returns the right string if I enter the URL into a browser. But it creates exceptions in the Java App (different issues with http and https server calls). https://www.problemio.com/auth/mobile_login.php?login=test.name@gmail.com&password=130989 Returns this string: [{“user_id”:”1601470″,”email”:”test.name@gmail.com”,”first_name”:”TestName”,”last_name”:null}] And this is the Java call…

create nested json file managing null values

I’m working with pyspark and I have the following code that creates a nested json file from a dataframe with some fields (product, quantity, from, to) nested in “requirements”. Herunder the code that creates the json an one row as example final2 = final.groupby(‘identifier’, ‘plant’, ‘family’, ‘familyDescription’, ‘type’, ‘name’, ‘description’, ‘batchSize’, ‘phantom’, ‘makeOrBuy’, ‘safetyStock’, ‘unit’,…

How to insert nested dictionary/json into MySQL table with Python

I’ve connected to the https://exchangeratesapi.io/ api like so: import requests, json, pymysql from db_credentials import db_config get_url = “https://api.exchangeratesapi.io/history?start_at=2018-01-01&end_at=2018-02-02&base=GBP” response = requests.get(get_url) results = response.content data = json.loads(results.decode(‘utf-8’))[‘rates’] print(data.keys()) print(data) data.keys() and data looks like this: dict_keys([‘2018-01-22’, ‘2018-01-09’, ‘2018-01-24’, ‘2018-01-03’, ‘2018-01-23’, ‘2018-01-25’, ‘2018-01-18’, ‘2018-02-02’, ‘2018-01-15’, ‘2018-01-02’, ‘2018-01-16’, ‘2018-01-11’, ‘2018-01-17’, ‘2018-01-12’, ‘2018-01-30’, ‘2018-02-01’, ‘2018-01-29’, ‘2018-01-08’, ‘2018-01-10’,…