Post: JFlex - A Basic Json Deserializer
05-27-2016, 05:00 AM #1
Mr Smithy x
Former Staff
(adsbygoogle = window.adsbygoogle || []).push({}); You must login or register to view this content.

It pretty much works with any class.
One this for sure is that it only supports int, Integer, String, Charsequence, double, Double, float, Float primitive and data types
I will support Custom classes and Parameterized List. I will have to do that recursively.

Preview:

You must login or register to view this content.


It also supports annotations in which you specifiy the node name.

    
public static class Wow{
@CUpdate(value = "cool") String cooli;
String value;
int score;
boolean isCool;
float f;
double d;
}

public static void main(String[] args) {
try {
Wow wow = (Wow) JFlex.fromJson(Wow.class, "{ \"cool\": \"hello\", \"value\":\"myCoolValue\", \"score\":5 , \"f\":0.2 , \"d\":0.62 , \"isCool\": true}");
System.out.println(wow.cooli);
System.out.println(wow.value);
System.out.println(wow.score);
System.out.println(wow.isCool);
System.out.println(wow.d);
System.out.println(wow.f);
} catch (Exception e) {
e.printStackTrace();
}
}

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo