An4rchy Posted June 23, 2013 Posted June 23, 2013 o.O I'm surprised that you use greek words to your posts. lol? I liked json since you first mentioned it Seth, because it's easier to use and you can simply save a whole .json file to a list(you can do it in jaxb too, but it's kinda complicated).
vegax987 Posted June 24, 2013 Posted June 24, 2013 JSON is a very good alternative to static XML datapack and I think it can outperform XML loading in L2j, we need benchmark tests anyway Tutorial: http://www.mkyong.com/java/json-simple-example-read-and-write-json/ XML to JSON: http://www.utilities-online.info/xmltojson
Setekh Posted June 24, 2013 Posted June 24, 2013 JSON is a very good alternative to static XML datapack and I think it can outperform XML loading in L2j, we need benchmark tests anyway Tutorial: http://www.mkyong.com/java/json-simple-example-read-and-write-json/ XML to JSON: http://www.utilities-online.info/xmltojson its all about managing json. Take a look at jackson @ codehouse
An4rchy Posted June 24, 2013 Posted June 24, 2013 Look at this: http://pastebin.com/JHT4ACBi And how it's loaded: public void load() { File f = new File("./data/json/teleports.json"); if (!f.exists()) { _log.severe("TeleportLocationTable: teleports.json could not be loaded: file not found"); return; } List<L2TeleportLocation> temp = JSONParser.getInstance().loadList("data/json/teleports.json", L2TeleportLocation.class); for (L2TeleportLocation tl : temp) { _teleports.put(tl.getTeleId(), tl); } _log.info("TeleportLocationTable: Loaded " + _teleports.size() + " templates."); } While in xml(without using jaxb): public void load() { try { File f = new File("./data/xml/teleports.xml"); Document doc = XMLDocumentFactory.getInstance().loadDocument(f); Node n = doc.getFirstChild(); for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) { if (d.getNodeName().equalsIgnoreCase("teleport")) { NamedNodeMap node = d.getAttributes(); L2TeleportLocation teleport = new L2TeleportLocation(); teleport.setTeleId(Integer.valueOf(node.getNamedItem("id").getNodeValue())); teleport.setLocX(Integer.valueOf(node.getNamedItem("loc_x").getNodeValue())); teleport.setLocY(Integer.valueOf(node.getNamedItem("loc_y").getNodeValue())); teleport.setLocZ(Integer.valueOf(node.getNamedItem("loc_z").getNodeValue())); teleport.setPrice(Integer.valueOf(node.getNamedItem("price").getNodeValue())); teleport.setIsForNoble(Integer.valueOf(node.getNamedItem("fornoble").getNodeValue()) == 1); _teleports.put(teleport.getTeleId(), teleport); } } } catch (Exception e) { _log.severe("TeleportLocationTable: Error while creating table" + e); } _log.info("TeleportLocationTable: Loaded " + _teleports.size() + " templates."); } Also when teleports.xml rewriten to teleports.json it was like half size.
Trance Posted June 24, 2013 Posted June 24, 2013 Also when teleports.xml rewriten to teleports.json it was like half size. Of course. HelperBuffTable using json. private void load() { JsonService service = JsonService.getInstance(); _helperBuff = service.loadList("data/json/helper_buffs.json", L2HelperBuff.class); for (L2HelperBuff buff : _helperBuff) { // Calulate the range level in wich player must be to obtain buff from Newbie Helper if (!buff.isMagicClassBuff()) { if (buff.getLowerLevel() < _physicClassLowestLevel) { _physicClassLowestLevel = buff.getLowerLevel(); } if (buff.getUpperLevel() > _physicClassHighestLevel) { _physicClassHighestLevel = buff.getUpperLevel(); } } else { if (buff.getLowerLevel() < _magicClassLowestLevel) { _magicClassLowestLevel = buff.getLowerLevel(); } if (buff.getUpperLevel() > _magicClassHighestLevel) { _magicClassHighestLevel = buff.getUpperLevel(); } } } _log.info("Helper Buff Table: Loaded " + _helperBuff.size() + " Templates."); }
Intrepid Posted June 24, 2013 Posted June 24, 2013 yet json is hard to edit, hard to read and just a nightmare to edit when it involves big stuff, json is a web language in general and should be used on the web only
An4rchy Posted June 24, 2013 Posted June 24, 2013 yet json is hard to edit, hard to read and just a nightmare to edit when it involves big stuff, json is a web language in general and should be used on the web only Well, it's not that bad. Actually you can't say it should only be used on web apps, since it is created in order to make a faster xml service(even the package in jackson lib is com.fasterxml lol). It's just kinda complicated, but really efficient too.
Intrepid Posted June 24, 2013 Posted June 24, 2013 Well, it's not that bad. Actually you can't say it should only be used on web apps, since it is created in order to make a faster xml service(even the package in jackson lib is com.fasterxml lol). It's just kinda complicated, but really efficient too. The creators of json said themselfs that json was implemented to replace XML on the web nowhere else, in l2j you need validation you need clear understanding of every element and you also need structure which json doesnt have. XML maybe harder to parse but when you check on the outcome it provides a better result for gameserver usage than json ever could.
An4rchy Posted June 25, 2013 Posted June 25, 2013 The creators of json said themselfs that json was implemented to replace XML on the web nowhere else, in l2j you need validation you need clear understanding of every element and you also need structure which json doesnt have. XML maybe harder to parse but when you check on the outcome it provides a better result for gameserver usage than json ever could. Xml though is useful only if you use jaxb(which is kinda difficult too when you are trying to unmarshal/marshal a list).
Setekh Posted June 25, 2013 Posted June 25, 2013 Xml though is useful only if you use jaxb(which is kinda difficult too when you are trying to unmarshal/marshal a list). jaxb made xml easy actually, its just a matter of understanding the annotations, tho its kind of annoying making so many classes to use them as protocols just to pass the data to another holder. Also XML was done by W3C, who wanna guess what they do in particular? The only downfall of json is that they dont have time stamps. And its easy to read, in fact easyest to read and write, basically there are thousands of editors.
Java-man Posted June 27, 2013 Posted June 27, 2013 Guys, good alternative to xml can be yaml, but not shit json.
Setekh Posted June 28, 2013 Posted June 28, 2013 Guys, good alternative to xml can be yaml, but not shit json. hahahaha its the same thing, im crying right nou of laughter hahahaha Also ill tell you why YAML should be always left as a config. Indent dependency.
An4rchy Posted June 28, 2013 Posted June 28, 2013 Guys, good alternative to xml can be yaml, but not shit json. You are not even using jaxb to load xml in aCis and you tell us about replacing it?
MissingNo. Posted June 28, 2013 Posted June 28, 2013 You are not even using jaxb to load xml in aCis and you tell us about replacing it? Your message doesn't make any sence.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now