question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Never ending deserialize

See original GitHub issue

Please ensure you have given all the following requested information in your report.

Issue details

Never ending deserialize Client send object to server correctly In server: try { String str=new String(message.array(), "UTF-8"); System.out.println(str); System.out.println("New object kk"); o = new Json().fromJson(null, str); System.out.println("New object kk2"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); }

Console:
New object 2
java.nio.HeapByteBuffer[pos=0 lim=36 cap=36]
{class:"dDev.tech.SpaceLoader",x:15}
New object kk

As you can see never prints new object kk2

Class of Space Loader
`public class SpaceLoader {
    public  int x=0;

   /* public SpaceLoader(){
        x=6;

    }*/
    public SpaceLoader(int x){
        this.x=x;
    }


    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }
}`

EDIT: If i put the commented constructor it works. It's weird

#### Reproduction steps/code


#### Version of LibGDX and/or relevant dependencies
Last verison

#### Stacktrace
```java
//Please provide the stacktrace if applicable 

Please select the affected platforms

  • [ x] Android
  • iOS
  • [x ] HTML/GWT
  • [x ] Windows
  • [ x] Linux
  • [x ] MacOS

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Tom-Skicommented, Apr 6, 2021

That is completely expected, you are using different constructors that populate the fields with different values, so the serialized representation of those instances would be different.

I suggest you use the discord if you need assistance, this is an issue tracker.

https://github.com/libgdx/libgdx/wiki/Getting-help

0reactions
dDevTechcommented, Apr 6, 2021

UPDATE: the previous problem was magically solver. However I came up with another bug/problem: This is my serializable class

public class SpaceLoader {
    public  int x=0;
    private String hi="tete";

    public SpaceLoader(){

    }
    public SpaceLoader(int x){
        this.x=x;


    }


}

If I use: String s=new JsonSerializer().serializeAsString(new SpaceLoader()); It prints: {class:“dDev.tech.serialized.SpaceLoader”}

However if I use the int constructor and not the default String s=new JsonSerializer().serializeAsString(new SpaceLoader(5)); It prints: {class:“dDev.tech.serialized.SpaceLoader”,x:5}

This is strange, right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

json - Await deserializing Task never ends c# - Stack Overflow
Problem is that the file can end up being very large, so deserializing asynchronously is a must. What I serialize and deserialize is...
Read more >
Serialization & Deserialization in c#.net - Learning Never Ends
In C#, Serialization is the process of converting an object into a stream of bytes to store the object it to memory, a...
Read more >
Serialization and deserialization in Java | Snyk Blog
Java serialization is a mechanism to transform an object into a byte stream. Java deserialization, on the other hand, allows us to recreate ......
Read more >
Deserialization - OWASP Cheat Sheet Series
Deserialization is the reverse of that process, taking data structured from some format, and rebuilding it into an object. Today, the most popular...
Read more >
Infinite loop when direct deserializing a List · Issue #61 - GitHub
When I try to deserialize the List of Message inside the Deserialize method of Packet the serializer never ends.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found