skip to Main Content

Json – Extracting values from String array from JWT object in Java?

So I am getting my JWT token with SecurityContext like so: JwtAuthenticationToken authToken = (JWTAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); if (authToken != null) { log.warn("Principal authorities:"); authToken.getAuthorities().forEach(auth -> log.warn("authorities: [{}]", auth.getAuthority())); Map<String, Object> attributes = Collections.emptyMap(); attributes = authToken.getTokenAttributes(); with my token looking…

VIEW QUESTION

Postgresql – Problem using json_array_elements to extract values from array of JSON Objects in Postgres

I have the following code in which I am trying to extract JSON as follows: DROP TABLE IF EXISTS tmp2; CREATE TEMP table tmp2 ( c TEXT ); insert into tmp2 values ( N'{"SerialNumber":"907578","SoftwareVersion":"1.2.777","Build":"4829","ProductCode":"TR-3500-A","BuildDate":null,"Description":"Study desk","ConnectionType":2,"Capabilities":[2,3], "ChannelListDto":[ {"ChannelId":0,"ConversionType":0,"DeviceSerialNumber":null,"Dimension":"","FixedName":null,"Name":"test2","InstrumentationChannel":-1,"IsAlarmable":false,"IsInternal":true,"IsEnableable":false,"IsEnabled":false,"JournalledReadingBytes":0,"LowerLimit":null,"Precision":null,"Symbol":"","TypeId":5,"UpperLimit":null}, {"ChannelId":1,"ConversionType":0,"DeviceSerialNumber":null,"Dimension":"","FixedName":null,"Name":null,"InstrumentationChannel":-1,"IsAlarmable":false,"IsInternal":true,"IsEnableable":false,"IsEnabled":false,"JournalledReadingBytes":0,"LowerLimit":null,"Precision":null,"Symbol":"","TypeId":5,"UpperLimit":null}, {"ChannelId":2,"ConversionType":0,"DeviceSerialNumber":null,"Dimension":"","FixedName":null,"Name":null,"InstrumentationChannel":-1,"IsAlarmable":false,"IsInternal":true,"IsEnableable":false,"IsEnabled":false,"JournalledReadingBytes":0,"LowerLimit":null,"Precision":null,"Symbol":"","TypeId":5,"UpperLimit":null} ]…

VIEW QUESTION

Json – Gson serialization fails without throwing errors

I have a pretty complex objects(I'm not posting the code because of that) I'm trying to serialize with these calls: Gson gson = new GsonBuilder().setPrettyPrinting().create(); PrintWriter output = new PrintWriter(new FileOutputStream("Hotels.json")); output.write(gson.toJson(myObject);); The program terminates with no failure but the…

VIEW QUESTION
Back To Top
Search