# Serialization and deserialization

**URL:** <https://discourse.processing.org/t/serialization-and-deserialization/6906>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [December 26, 2018, 2:53pm UTC](https://discourse.processing.org/t/serialization-and-deserialization/6906 "2018-12-26T14:53:03Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![dector](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dector/32/2944_2.png) [@dector](https://discourse.processing.org/u/dector)\
**Post date:** [January 3, 2019, 10:21pm UTC](https://discourse.processing.org/t/serialization-and-deserialization/6906/21 "2019-01-03T22:21:18Z")

</div>

Answering both questions with simplified code:

```java
if (SerialPort.available() > 0) {
      for (Field field : fields) {
          Type type = field.getType();

          if (type == boolean.class) { field.setByte(this, SerialPort.readByte()); }
          else if (type == byte.class) { field.setByte(this, SerialPort.readByte()); }
          // ...

```

Reading `Integer` will be reading 4 bytes with

```java
// Declared once somewhere
byte[] buffer = byte[4];
// ...
SerialPort.readBytes(buffer);
int value = convert_to_big_endian(buffer); // Or just use small ByteBuffer

```

---

<div class="post-metadata">

**Author:** ![MoonMoon](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@MoonMoon](https://discourse.processing.org/u/MoonMoon)\
**Post date:** [January 4, 2019, 9:56pm UTC](https://discourse.processing.org/t/serialization-and-deserialization/6906/22 "2019-01-04T21:56:42Z")

</div>

Ok thank you very much!

But at least a short question… I switched on autocompletion in Procession. Now if I add a new file like SerialTransmission.java the autocompletion doesn’t work anymore in this sketch.

Doesn’t Processing support java files and autocompletion? Is there an workaround?  
I’m not lazy, it’s just easier to find the right methods/variables 😉

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [January 5, 2019, 11:57am UTC](https://discourse.processing.org/t/serialization-and-deserialization/6906/23 "2019-01-05T11:57:52Z")

</div>

> [@MoonMoon](#):
>
> Doesn’t Processing support “.java” files and autocompletion?

Tabs w/ “.java” file extensions are outta limits of PDE’s pre-processor. 🙈  
In those kinda tabs, code has to be written w/ 100% Java compliant syntax. ☕

[Previous page](https://discourse.processing.org/t/serialization-and-deserialization/6906.md?page=1)
