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);
|
}
|
|
}
|
}
|