Alejandro Acuña
2024-08-12 831c7bd85763b5eb5ef46664c65f0181824f9e13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package art.servers.transactionsserver.test.serialization;
 
import art.library.interop.serialization.Serialization;
import art.library.interop.serialization.SerializationException;
import art.library.model.devices.user.User;
import art.library.model.devices.user.UserInformation;
import art.library.utils.licence.Licence;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.logging.Level;
import java.util.logging.Logger;
 
public class TestDeserializeArrayString
{
 
    public static void main(String[] args)
    {
        try
        {
            System.out.println(Serialization.toString(new String[]{"superfranco"}));
            
            //String bodyContent = "[\"user\"]";
            //String[] luser = (String[])(Serialization.deserialize(String[].class, bodyContent));
            User user1 = new User();
            user1.information = new UserInformation();
            user1.getDeviceInformation().group = "Administrator";
            user1.username = Licence.encrypt("gddkia");
            user1.getDeviceInformation().role = "Administrator";
            user1.getDeviceInformation().password = Licence.encrypt("gddkia123$%^");
            System.out.println(Serialization.toString(user1));
 
            //String bodyContent0 = "{\"User\":{\"User\":{\"Device information\":{\"User information\":{\"Role\":\"Administrator\",\"Password\":\"626d77\"}},\"Username\":\"root2\"}}}";
            //String bodyContent1 = "{\"User\":{\"Device information\":{\"Role\":\"Administrator\",\"Password\":\"626d77\"}},\"Username\":\"root2\"}";
            //String bodyContent2 = "{\"User\":{\"Device information\":{\"User information\":{\"Role\":\"Administrator\",\"Password\":\"pass\"}},\"Username\":\"user\"}}";
            //User user = (User) (Serialization.deserialize(User.class, bodyContent1));
            
            String bodyContentAction = "[\n"
                    + "  {\n"
                    + "    \"User information\": {\n"
                    + "      \"Server port\": 0,\n"
                    + "      \"Number\": 0,\n"
                    + "      \"Group\": \"Operator\",\n"
                    + "      \"Name\": \"operator\",\n"
                    + "      \"Latitude\": 0,\n"
                    + "      \"Longitude\": 0,\n"
                    + "      \"Symbol color\": 0,\n"
                    + "      \"Role\": \"Write\",\n"
                    + "      \"Password\": \"Q7vX+jcblHhAyALfhCMxYw==\",\n"
                    + "      \"Creation date\": \"1970-01-01T00:00:00.000Z\"\n"
                    + "    }\n"
                    + "  },\n"
                    + "  {\n"
                    + "    \"User information\": {\n"
                    + "      \"Server port\": 0,\n"
                    + "      \"Number\": 0,\n"
                    + "      \"Group\": \"Operator\",\n"
                    + "      \"Name\": \"operator2\",\n"
                    + "      \"Latitude\": 0,\n"
                    + "      \"Longitude\": 0,\n"
                    + "      \"Symbol color\": 0,\n"
                    + "      \"Role\": \"Write\",\n"
                    + "      \"Password\": \"Q7vX+jcblHhAyALfhCMxYw==\",\n"
                    + "      \"Creation date\": \"1970-01-01T00:00:00.000Z\"\n"
                    + "    }\n"
                    + "  }\n"
                    + "]";
            ObjectMapper mapper = new ObjectMapper();
            Object json = mapper.readValue(bodyContentAction, UserInformation[].class);
            
        } catch (SerializationException ex)
        {
            Logger.getLogger(TestDeserializeArrayString.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex)
        {
            Logger.getLogger(TestDeserializeArrayString.class.getName()).log(Level.SEVERE, null, ex);
        }
 
    }
}