#(pobab) make JsonObject from CharSequence in java

16 messages · Page 1 of 1 (latest)

empty rain
#

im trying to bridge donation platform to be used in Forge. but the PARSER make the data get stuck and wont run the method properly, i can't see any error in the console either

here is what i've been do:
ForgeriaWebSocketClient.java

public CompletionStage<?> onText(WebSocket ws, CharSequence data, boolean last) {
    LOGGER.info("[Forgeria] Data: " + MessageParser.parse(data.toString()));
    return WebSocket.Listener.super.onText(ws, data, last);
}

MessageParser.java

public static List<IncomingDonation> parse(String payload) {
    LOGGER.info("[Forgeria] MessageParse 1");
    List<IncomingDonation> result = new ArrayList<>();
    // BUG: parser make the data got stuck
    JsonObject obj = PARSER.parse(payload).getAsJsonObject();
    LOGGER.info("[Forgeria] MessageParse 2");
    String type = obj.get("type").getAsString();
    if ("donations".equals(type)) {
        JsonArray jData = obj.get("data").getAsJsonArray();
        for (JsonElement el : jData) {
            JsonObject jdonation = el.getAsJsonObject();
            int amount = jdonation.get("amount").getAsNumber().intValue();
            String name = jdonation.get("donator").getAsString();
            String message = jdonation.get("message").getAsString();
            boolean replay = jdonation.has("is_replay") && jdonation.get("is_replay").getAsBoolean();
            IncomingDonation incomingDonation = new IncomingDonation.Builder()
                    .setAmount(amount)
                    .setName(name)
                    .setMessage(message)
                    .setReplay(replay)
                    .build();
            result.add(incomingDonation);
        }
    }
    return result;
}
supple bronzeBOT
#

(pobab) make JsonObject from CharSequence in java

supple bronzeBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

empty rain
#

it wont print LOGGER.info("[Forgeria] MessageParse 2"); after i try to send a notify test

#

how it look in console before i send a notify test

#

:(

empty rain
#

i think i knew what it causes. it was the length of CharSequence

#

it was 9451 length 😱

#

i wonder how to i get a specific data if it was CharSequence

#

i think it should use subSequence

#

any other idea guys?

empty rain
#

ok, i solve it by my self. i just realize if i cant parse a lot char at a time into JsonObject. the data are too long because i turn on the TTS (Text To Speech)

#

it entertaining... i need talk to someone who can look into this conversation, then... i solve my problem by my self with using a question on the issue