Jump to content

Recommended Posts

Posted

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).

Posted

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

Posted

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

Posted

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.

Posted

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.");
}

Posted

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

Posted

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.

Posted

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.

Posted

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).

Posted

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.

 

Posted

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.

Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...