Mined Opinions For API: sax

This tab contains all the opinions collected from Stack Overflow about the API. The other tabs present summaries of the opinions using different algorithms.
  • For this sort of translation from one format to another, SAX is ideal.. details
  • Haha, so true.. details
  • It's like SAX parsing for XML.. details
  • To prevent all the object creation, look at event driven xml and json handling like URL_http://www.saxproject.org/ [SAX] for XML and URL_http://code.google.com/p/json-simple/ [Json-Simple] and/or URL_http://jackson.codehaus.org/ [Jackson] for JSON.. details
  • I have 3 sections (named arrays) in some huge file.It successfully parses first (a tiny one, under 1000 bytes).. details
  • For one object in values I call nextObject.put.. details
  • Nothing special.. details
  • Next array has nested array with simple objects (like this): CODESNIPPET_JAVA3 .. details
  • It's not a JSON problem: it perfectly being mapped on iOS.. details
  • currentParser.getCurrentName() is runs successfully and returns correct string, but currentParser.getText() fails.. details
  • It's not a JSON problem: it perfectly being mapped on iOS.. details
  • Most likely this will mean to use your own JSON tokenizer that does not build a full tree, but which is able to (like a SAX parser) only look at a part of the object tree at a time.. details
  • It is basically like a chatty person telling you everything they are doing AS they do it.. details
  • Then you just pass that rule to the parser when you create it, like this: CODESNIPPET_JAVA2 .. details
  • Use an XML parser like URL_http://www.saxproject.org/ [SAX] instead of a JSON parser.. details
  • So the ability to parse JSON using a SAX handler gives you an easy mechanism to build a DOM tree out of a JSON structure in Java.. details
  • Good point; maybe it's not so much for SAX, but SAX style (incremental processing, instead of tree model).. details
  • The point of json is to not parse it like xml.. details
  • And if you truly want SAX, writing wrapper from Stax to SAX is trivial as well (but not the other way around).. details
  • URL_http://code.google.com/p/json-simple/ [ URL_http://code.google.com/p/json-simple/ ] Stoppable SAX-like interface for streaming input of JSON text 2.. details
  • Is there a SaxParser that reads json and fires events so it looks like xml.. details
  • This would be great as it would allow my xml stuff to read json w/out any change except for the different sax parser.. details
  • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop.I had it going before but I cant find it again.. details
  • There are several ways to parse JSON with it: Streaming (like Sax) Tree (like DOM) Object-mapped (like JAXB) EDIT: Take org.json classes, there are URL_http://developer.android.com/reference/org/json/package-summary.html [already-in] the android API.. details
  • EDIT 2** Maybe what you need is a "SAX like" JSON parser; e.g.. details
  • As it is designed for micro edition, it is really light-weight (small footprint) and IMHO really easy to use (much more easier than SAX/DOM etc.. details
  • As it is designed for micro edition, it is really light-weight (small footprint) and IMHO really easy to use (much more easier than SAX/DOM etc.. details
  • The choice of SAX/DOM is really basde on what you're trying to parse, see this for how to decide on which one to use: URL_http://geekexplains.blogspot.com/2009/04/sax-vs-dom-differences-between- dom-and.html [ URL_http://geekexplains.blogspot.com/2009/04/sax-vs-dom-differences - between-dom-and.html] Even if you don't use SAX/DOM there are still simple options available to you, take a look at Simple : ) URL_http://simple.sourceforge.net/ [ URL_http://simple.sourceforge.net/ ] You may also want to consider STaX.. details
  • SAX itself is very lightweight and fast, so I'm not sure why think it's too much.. details
  • SAX itself is very lightweight and fast, so I'm not sure why think it's too much.. details
  • Thanks //edit Thanks for the responses so far :) The xml will be between 3/4 lines to about 50 max (at the extreme).. .. details
  • Thanks, I will have a look at simple.. details
  • SAX is about the most efficient way possible to read XML in Java.. details
  • + Dom4j has SAX-like API but easier.. details
  • I suspect that by "lightweight", Joe means "is easy to use"; SAX' callback- oriented API is not the most user-friendly.. details
  • The SAX reader tells you what tags are seen and then gives the values for those tags.. details
  • JSON is pretty simple to parse, and these tools tend to be pretty small so this shouldn't be a big deal.. details
  • You could also use XML pull here, which tends to be a little faster JSON: take a look at some of the open source JSON libraries and do some tweaking.. details
  • Yes, JSON does have a toXML and you can make JSON.XMLtoJSON, but i need to add extra bits, and change a few bits around to satisfy the dojo requirements.As the quick bursts will be very strict in format, and typically be 3/4 lines line (50 at the most a (a recurring set of 3/4 line elements) holding in memory will not be too much of an issue..Thanks again for the comments so far... details
  • establishing a context that lets you know when a JSON string has finished syntactically, without loading the whole thing into memory), you could look into event-based parsers (similar to what SAX does with XML).. details
  • Yes, JSON does have a toXML and you can make JSON.XMLtoJSON, but i need to add extra bits, and change a few bits around to satisfy the dojo requirements.As the quick bursts will be very strict in format, and typically be 3/4 lines line (50 at the most a (a recurring set of 3/4 line elements) holding in memory will not be too much of an issue..Thanks again for the comments so far... details
  • If it's the size of the file you're worried about, then you should use the 'SAX' style example.. details
  • Although JSON does seem less verbose (no closing tags for example), and is also provides a very easy means to pass data to Javascript, which is all the rage these days and hence probably one of the reasons for the big rise of JSON.. details
  • Although JSON does seem less verbose (no closing tags for example), and is also provides a very easy means to pass data to Javascript, which is all the rage these days and hence probably one of the reasons for the big rise of JSON.. details
  • Yes, that is what I was trying to express : a single file big json array, and a single call for parsing, could seem easier, but could also mean loading everything in ram; while going "step by step" could you let handle entities one by one ... this is SAX against DOM again, but now that it is called JSON it makes it sound much more k00l.. details
  • It's not an object or iterator creation problem: I can delete that where parser throws exception, but it will fail in the same place.. details
  • I tried to use BufferedInputStream with predefined block size instead of InputStream but it had no effect.. details
  • Jackson SAX parser throws exception when parsing huge JSON.. details
  • I spent more than a year working on this while writing a really robust Feed- parsing system that started off as a SAX-based system, then moved to STAX and the more I worked on it the more I realized how easily I could abstract out the pain of STAX with simple rules.. details
  • If you're working with Perl its easy to turn a JSON string into a deep structure you can manipulate easily, but not so with Java.. details
  • I must agree with Falmarri, JSON != XML, and one should only result to emulation as last effort if nothing else works.However, maybe original asker wanted something LIKE sax API, not SAX API -- SAX API makes no sense since it's xml-specific; but push style approach is generic.But this all depends on whether question is specifically about SAX (simple api for XML, very xml specific), or about streaming/incremental parsing approach, which is more general.. details
  • However XML and JSON are different enough in structure that I really doubt you could have 100% code compatibility, to use XML-oriented SAX-processing code when consuming JSON.. details
  • For example, there are many data binding tools for both XML and JSON; and using such tools could hide lower level details much better than using abstraction meant for one to process the other.. details
  • Also using a string buffer would actually be much less scalable** then using SAX because SAX doesn't require you to load the whole XML file into memory to use it.. details
  • Also using a string buffer would actually be much less scalable** then using SAX because SAX doesn't require you to load the whole XML file into memory to use it.. details
  • Java's implementation can be kind of annoying to use (You create a document by using a DocumentBuilder, which comes from a DocumentBuilderFactory) The code to create a document from a file looks like this: CODESNIPPET_JAVA1 .. details
  • If you have small files and you don't need to worry about performance, look into using the DOM.. details
  • If you have small files and you don't need to worry about performance, look into using the DOM.. details
  • Basically, under the covers I assume all HTML parsers will spin thru the string (or memory buffer) and parse, producing output on the way through.. details
  • Basically, under the covers I assume all HTML parsers will spin thru the string (or memory buffer) and parse, producing output on the way through.. details
  • Plus, I have my own SAX utilities that add tag name based dispatch and an object stack which makes this stuff even more trivial sometimes.. details
  • @PSpeed: IMHO SAX is not ideal, because event driven approach of SAX is harder to understand and use than pull parsing approach (of kXML parser or similar).. details
  • If there is little translation then it may be extremely tiny.. details
  • Otherwise, reading JSON or XML is a little trickier, but not too bad I assume you already have some means of indexing the objects you want to merge into (like a Map of some sort) I assume you already have some means to know which property is the key that uniquely identifies an object (I assume last name is just to get the point across, as it would make a bad key) XML: For this type of use, I'd recommend a SAX reader for the xml - you'll need a stack to keep track of which objects you're adding data to.. details
Summaries the opinions about sax using topic modeling.
  • 0. simple html stax lightweight decide choice option basde callback find: 7
    • Haha, so true.. details
    • And if you truly want SAX, writing wrapper from Stax to SAX is trivial as well (but not the other way around).. details
    • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop.I had it going before but I cant find it again.. details
    • The choice of SAX/DOM is really basde on what you're trying to parse, see this for how to decide on which one to use: dom-and.html [ - between-dom-and.html] Even if you don't use SAX/DOM there are still simple options available to you, take a look at Simple : ) You may also want to consider STaX.. details
    • SAX itself is very lightweight and fast, so I'm not sure why think it's too much.. details
    • Thanks, I will have a look at simple.. details
    • I suspect that by "lightweight", Joe means "is easy to use"; SAX' callback- oriented API is not the most user-friendly.. details
  • 1. tag simple edit tend deal mapped stream tool big jaxb: 3
    • There are several ways to parse JSON with it: Streaming (like Sax) Tree (like DOM) Object-mapped (like JAXB) EDIT: Take org.json classes, there are already-in the android API.. details
    • JSON is pretty simple to parse, and these tools tend to be pretty small so this shouldn't be a big deal.. details
    • The SAX reader tells you what tags are seen and then gives the values for those tags.. details
  • 2. read chatty person saxparser fire basically call nextobject simple point: 3
    • For one object in values I call nextObject.put.. details
    • It is basically like a chatty person telling you everything they are doing AS they do it.. details
    • Is there a SaxParser that reads json and fires events so it looks like xml.. details
  • 3. edit stream text input response stoppable byte huge extreme tiny: 4
    • I have 3 sections (named arrays) in some huge file.It successfully parses first (a tiny one, under 1000 bytes).. details
    • Stoppable SAX-like interface for streaming input of JSON text 2.. details
    • EDIT 2** Maybe what you need is a "SAX like" JSON parser; e.g.. details
    • Thanks //edit Thanks for the responses so far :) The xml will be between 3/4 lines to about 50 max (at the extreme).. .. details
  • 4. read point build time full stuff tokenizer incremental model change: 6
    • It's like SAX parsing for XML.. details
    • Most likely this will mean to use your own JSON tokenizer that does not build a full tree, but which is able to (like a SAX parser) only look at a part of the object tree at a time.. details
    • Good point; maybe it's not so much for SAX, but SAX style (incremental processing, instead of tree model).. details
    • The point of json is to not parse it like xml.. details
    • This would be great as it would allow my xml stuff to read json w/out any change except for the different sax parser.. details
    • SAX is about the most efficient way possible to read XML in Java.. details
  • 5. simple drive prevent jackson creation rule create pass nest point: 3
    • To prevent all the object creation, look at event driven xml and json handling like SAX for XML and Json-Simple and/or Jackson for JSON.. details
    • Next array has nested array with simple objects (like this): CODESNIPPET .. details
    • Then you just pass that rule to the parser when you create it, like this: CODESNIPPET .. details
  • 6. currentparser weight build micro edition light return ability imho structure: 9
    • For this sort of translation from one format to another, SAX is ideal.. details
    • It's not a JSON problem: it perfectly being mapped on iOS.. details
    • currentParser.getCurrentName() is runs successfully and returns correct string, but currentParser.getText() fails.. details
    • Nothing special.. details
    • Use an XML parser like SAX instead of a JSON parser.. details
    • So the ability to parse JSON using a SAX handler gives you an easy mechanism to build a DOM tree out of a JSON structure in Java.. details
    • As it is designed for micro edition, it is really light-weight (small footprint) and IMHO really easy to use (much more easier than SAX/DOM etc.. details
    • + Dom4j has SAX-like API but easier.. details
    • You could also use XML pull here, which tends to be a little faster JSON: take a look at some of the open source JSON libraries and do some tweaking.. details
  • 0. assume tool structure key single step call process low hide: 5
    • Yes, that is what I was trying to express : a single file big json array, and a single call for parsing, could seem easier, but could also mean loading everything in ram; while going "step by step" could you let handle entities one by one ... this is SAX against DOM again, but now that it is called JSON it makes it sound much more k00l.. details
    • If you're working with Perl its easy to turn a JSON string into a deep structure you can manipulate easily, but not so with Java.. details
    • However XML and JSON are different enough in structure that I really doubt you could have 100% code compatibility, to use XML-oriented SAX-processing code when consuming JSON.. details
    • For example, there are many data binding tools for both XML and JSON; and using such tools could hide lower level details much better than using abstraction meant for one to process the other.. details
    • Otherwise, reading JSON or XML is a little trickier, but not too bad I assume you already have some means of indexing the objects you want to merge into (like a Map of some sort) I assume you already have some means to know which property is the key that uniquely identifies an object (I assume last name is just to get the point across, as it would make a bad key) XML: For this type of use, I'd recommend a SAX reader for the xml - you'll need a stack to keep track of which objects you're adding data to.. details
  • 1. approach specific tag big parsing emulation stream general simple agree: 9
    • If it's the size of the file you're worried about, then you should use the 'SAX' style example.. details
    • Although JSON does seem less verbose (no closing tags for example), and is also provides a very easy means to pass data to Javascript, which is all the rage these days and hence probably one of the reasons for the big rise of JSON.. details
    • I tried to use BufferedInputStream with predefined block size instead of InputStream but it had no effect.. details
    • I must agree with Falmarri, JSON != XML, and one should only result to emulation as last effort if nothing else works.However, maybe original asker wanted something LIKE sax API, not SAX API -- SAX API makes no sense since it's xml-specific; but push style approach is generic.But this all depends on whether question is specifically about SAX (simple api for XML, very xml specific), or about streaming/incremental parsing approach, which is more general.. details
    • If you have small files and you don't need to worry about performance, look into using the DOM.. details
    • Basically, under the covers I assume all HTML parsers will spin thru the string (or memory buffer) and parse, producing output on the way through.. details
    • Plus, I have my own SAX utilities that add tag name based dispatch and an object stack which makes this stuff even more trivial sometimes.. details
    • @PSpeed: IMHO SAX is not ideal, because event driven approach of SAX is harder to understand and use than pull parsing approach (of kXML parser or similar).. details
    • If there is little translation then it may be extremely tiny.. details
  • 2. create throw exception creation documentbuilderfactory delete place iterator kind implementation: 2
    • It's not an object or iterator creation problem: I can delete that where parser throws exception, but it will fail in the same place.. details
    • Java's implementation can be kind of annoying to use (You create a document by using a DocumentBuilder, which comes from a DocumentBuilderFactory) The code to create a document from a file looks like this: CODESNIPPET .. details
  • 3. bit load based system stax add dojo toxml typically comment: 5
    • establishing a context that lets you know when a JSON string has finished syntactically, without loading the whole thing into memory), you could look into event-based parsers (similar to what SAX does with XML).. details
    • Yes, JSON does have a toXML and you can make JSON.XMLtoJSON, but i need to add extra bits, and change a few bits around to satisfy the dojo requirements.As the quick bursts will be very strict in format, and typically be 3/4 lines line (50 at the most a (a recurring set of 3/4 line elements) holding in memory will not be too much of an issue..Thanks again for the comments so far... details
    • Jackson SAX parser throws exception when parsing huge JSON.. details
    • I spent more than a year working on this while writing a really robust Feed- parsing system that started off as a SAX-based system, then moved to STAX and the more I worked on it the more I realized how easily I could abstract out the pain of STAX with simple rules.. details
    • Also using a string buffer would actually be much less scalable** then using SAX because SAX doesn't require you to load the whole XML file into memory to use it.. details
Summaries of the opinions about sax using three algorithms (Textrank, Lexrank and Luhn) adopted from extractive summarization. Each algorithm was used once for the positive opinions and once for the negative opinions.
  • Dom4j has SAX like API but easier .
  • Most likely this will mean to use your own JSON tokenizer that does not build a full tree, but which is able to (like a SAX parser) only look at a part of the object tree at a time .
  • The point of json is to not parse it like xml .
  • There are several ways to parse JSON with it: Streaming (like Sax) Tree (like DOM) Object mapped (like JAXB) EDIT: Take org json classes, there are already in the android API .
  • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop I had it going before but I cant find it again .
  • To prevent all the object creation, look at event driven xml and json handling like SAX for XML and Json Simple and or Jackson for JSON .
  • Use an XML parser like SAX instead of a JSON parser .
  • SAX is about the most efficient way possible to read XML in Java .
  • The choice of SAX DOM is really basde on what you're trying to parse, see this for how to decide on which one to use: dom and html between dom and html Even if you don't use SAX DOM there are still simple options available to you, take a look at Simple : ) You may also want to consider STaX .
  • Thanks, I will have a look at simple .
  • As it is designed for micro edition, it is really light weight (small footprint) and IMHO really easy to use (much more easier than SAX DOM etc .
  • You could also use XML pull here, which tends to be a little faster JSON: take a look at some of the open source JSON libraries and do some tweaking .
  • Most likely this will mean to use your own JSON tokenizer that does not build a full tree, but which is able to (like a SAX parser) only look at a part of the object tree at a time .
  • The point of json is to not parse it like xml .
  • So the ability to parse JSON using a SAX handler gives you an easy mechanism to build a DOM tree out of a JSON structure in Java .
  • And if you truly want SAX, writing wrapper from Stax to SAX is trivial as well (but not the other way around) .
  • There are several ways to parse JSON with it: Streaming (like Sax) Tree (like DOM) Object mapped (like JAXB) EDIT: Take org json classes, there are already in the android API .
  • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop I had it going before but I cant find it again .
  • To prevent all the object creation, look at event driven xml and json handling like SAX for XML and Json Simple and or Jackson for JSON .
  • The choice of SAX DOM is really basde on what you're trying to parse, see this for how to decide on which one to use: dom and html between dom and html Even if you don't use SAX DOM there are still simple options available to you, take a look at Simple : ) You may also want to consider STaX .
  • As it is designed for micro edition, it is really light weight (small footprint) and IMHO really easy to use (much more easier than SAX DOM etc .
  • You could also use XML pull here, which tends to be a little faster JSON: take a look at some of the open source JSON libraries and do some tweaking .
  • JSON is pretty simple to parse, and these tools tend to be pretty small so this shouldn't be a big deal .
  • Most likely this will mean to use your own JSON tokenizer that does not build a full tree, but which is able to (like a SAX parser) only look at a part of the object tree at a time .
  • So the ability to parse JSON using a SAX handler gives you an easy mechanism to build a DOM tree out of a JSON structure in Java .
  • There are several ways to parse JSON with it: Streaming (like Sax) Tree (like DOM) Object mapped (like JAXB) EDIT: Take org json classes, there are already in the android API .
  • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop I had it going before but I cant find it again .
  • To prevent all the object creation, look at event driven xml and json handling like SAX for XML and Json Simple and or Jackson for JSON .
  • Thanks edit Thanks for the responses so far :) The xml will be between 3 4 lines to about 50 max (at the extreme) .
  • The choice of SAX DOM is really basde on what you're trying to parse, see this for how to decide on which one to use: dom and html between dom and html Even if you don't use SAX DOM there are still simple options available to you, take a look at Simple : ) You may also want to consider STaX .
  • Yes, JSON does have a toXML and you can make JSON XMLtoJSON, but i need to add extra bits, and change a few bits around to satisfy the dojo requirements As the quick bursts will be very strict in format, and typically be 3 4 lines line (50 at the most a (a recurring set of 3 4 line elements) holding in memory will not be too much of an issue Thanks again for the comments so far .
  • Otherwise, reading JSON or XML is a little trickier, but not too bad I assume you already have some means of indexing the objects you want to merge into (like a Map of some sort) I assume you already have some means to know which property is the key that uniquely identifies an object (I assume last name is just to get the point across, as it would make a bad key) XML: For this type of use, I'd recommend a SAX reader for the xml you'll need a stack to keep track of which objects you're adding data to .
  • Jackson SAX parser throws exception when parsing huge JSON .
  • I must agree with Falmarri, JSON != XML, and one should only result to emulation as last effort if nothing else works However, maybe original asker wanted something LIKE sax API, not SAX API SAX API makes no sense since it's xml specific; but push style approach is generic But this all depends on whether question is specifically about SAX (simple api for XML, very xml specific), or about streaming incremental parsing approach, which is more general .
  • If you're working with Perl its easy to turn a JSON string into a deep structure you can manipulate easily, but not so with Java .
  • If it's the size of the file you're worried about, then you should use the 'SAX' style example .
  • establishing a context that lets you know when a JSON string has finished syntactically, without loading the whole thing into memory), you could look into event based parsers (similar to what SAX does with XML) .
  • I spent more than a year working on this while writing a really robust Feed parsing system that started off as a SAX based system, then moved to STAX and the more I worked on it the more I realized how easily I could abstract out the pain of STAX with simple rules .
  • Also using a string buffer would actually be much less scalable** then using SAX because SAX doesn't require you to load the whole XML file into memory to use it .
  • Although JSON does seem less verbose (no closing tags for example), and is also provides a very easy means to pass data to Javascript, which is all the rage these days and hence probably one of the reasons for the big rise of JSON .
  • Yes, JSON does have a toXML and you can make JSON XMLtoJSON, but i need to add extra bits, and change a few bits around to satisfy the dojo requirements As the quick bursts will be very strict in format, and typically be 3 4 lines line (50 at the most a (a recurring set of 3 4 line elements) holding in memory will not be too much of an issue Thanks again for the comments so far .
  • Otherwise, reading JSON or XML is a little trickier, but not too bad I assume you already have some means of indexing the objects you want to merge into (like a Map of some sort) I assume you already have some means to know which property is the key that uniquely identifies an object (I assume last name is just to get the point across, as it would make a bad key) XML: For this type of use, I'd recommend a SAX reader for the xml you'll need a stack to keep track of which objects you're adding data to .
  • However XML and JSON are different enough in structure that I really doubt you could have 100% code compatibility, to use XML oriented SAX processing code when consuming JSON .
  • I must agree with Falmarri, JSON != XML, and one should only result to emulation as last effort if nothing else works However, maybe original asker wanted something LIKE sax API, not SAX API SAX API makes no sense since it's xml specific; but push style approach is generic But this all depends on whether question is specifically about SAX (simple api for XML, very xml specific), or about streaming incremental parsing approach, which is more general .
  • establishing a context that lets you know when a JSON string has finished syntactically, without loading the whole thing into memory), you could look into event based parsers (similar to what SAX does with XML) .
  • I spent more than a year working on this while writing a really robust Feed parsing system that started off as a SAX based system, then moved to STAX and the more I worked on it the more I realized how easily I could abstract out the pain of STAX with simple rules .
  • Also using a string buffer would actually be much less scalable** then using SAX because SAX doesn't require you to load the whole XML file into memory to use it .
  • Java's implementation can be kind of annoying to use (You create a document by using a DocumentBuilder, which comes from a DocumentBuilderFactory) The code to create a document from a file looks like this: CODESNIPPET JAVA1 .
  • Yes, that is what I was trying to express : a single file big json array, and a single call for parsing, could seem easier, but could also mean loading everything in ram; while going "step by step" could you let handle entities one by one this is SAX against DOM again, but now that it is called JSON it makes it sound much more k00l .
  • Although JSON does seem less verbose (no closing tags for example), and is also provides a very easy means to pass data to Javascript, which is all the rage these days and hence probably one of the reasons for the big rise of JSON .
  • Yes, JSON does have a toXML and you can make JSON XMLtoJSON, but i need to add extra bits, and change a few bits around to satisfy the dojo requirements As the quick bursts will be very strict in format, and typically be 3 4 lines line (50 at the most a (a recurring set of 3 4 line elements) holding in memory will not be too much of an issue Thanks again for the comments so far .
  • Otherwise, reading JSON or XML is a little trickier, but not too bad I assume you already have some means of indexing the objects you want to merge into (like a Map of some sort) I assume you already have some means to know which property is the key that uniquely identifies an object (I assume last name is just to get the point across, as it would make a bad key) XML: For this type of use, I'd recommend a SAX reader for the xml you'll need a stack to keep track of which objects you're adding data to .
  • I must agree with Falmarri, JSON != XML, and one should only result to emulation as last effort if nothing else works However, maybe original asker wanted something LIKE sax API, not SAX API SAX API makes no sense since it's xml specific; but push style approach is generic But this all depends on whether question is specifically about SAX (simple api for XML, very xml specific), or about streaming incremental parsing approach, which is more general .
  • If you're working with Perl its easy to turn a JSON string into a deep structure you can manipulate easily, but not so with Java .
  • establishing a context that lets you know when a JSON string has finished syntactically, without loading the whole thing into memory), you could look into event based parsers (similar to what SAX does with XML) .
  • I spent more than a year working on this while writing a really robust Feed parsing system that started off as a SAX based system, then moved to STAX and the more I worked on it the more I realized how easily I could abstract out the pain of STAX with simple rules .
  • Also using a string buffer would actually be much less scalable** then using SAX because SAX doesn't require you to load the whole XML file into memory to use it .
  • Java's implementation can be kind of annoying to use (You create a document by using a DocumentBuilder, which comes from a DocumentBuilderFactory) The code to create a document from a file looks like this: CODESNIPPET JAVA1 .
  • Yes, that is what I was trying to express : a single file big json array, and a single call for parsing, could seem easier, but could also mean loading everything in ram; while going "step by step" could you let handle entities one by one this is SAX against DOM again, but now that it is called JSON it makes it sound much more k00l .
  • Although JSON does seem less verbose (no closing tags for example), and is also provides a very easy means to pass data to Javascript, which is all the rage these days and hence probably one of the reasons for the big rise of JSON .
Summaries of the opinions about sax using Opinosis, an abstractive summarizer of opinions..
Summaries of the opinions about sax using contrastive viewpoints. Each entry contains a pair of positive and negative sentences that are most likely discussing about similar API features.
    • Good point; maybe it's not so much for SAX, but SAX style (incremental processing, instead of tree model) .
    • If it's the size of the file you're worried about, then you should use the 'SAX' style example .
Summaries of opinions about based on specific API aspects, such as, performance, usability, etc. The 'Overview' page provides an overview of the aspects detected in the opinions. The 'Trend' page shows the distribution of polarity over time for each aspect. The 'Positive Opinions' page groups positive opinions by the detected aspects. The 'Contrastive By Aspect' page shows paris of contrastive opinions under each aspect (where found).
Features:
  • Haha, so true.
  • If there is little translation then it may be extremely tiny.
Onlysentiment:
  • Thanks, I will have a look at simple.
  • N/A
Performance:
  • As it is designed for micro edition, it is really light-weight (small footprint) and IMHO really easy to use (much more easier than SAX/DOM etc.
  • Yes, JSON does have a toXML and you can make JSON.XMLtoJSON, but i need to add extra bits, and change a few bits around to satisfy the dojo requirements.As the quick bursts will be very strict in format, and typically be 3/4 lines line (50 at the most a (a recurring set of 3/4 line elements) holding in memory will not be too much of an issue..Thanks again for the comments so far..
Bug:
  • It's not a JSON problem: it perfectly being mapped on iOS.
  • Jackson SAX parser throws exception when parsing huge JSON.
Usability:
  • For this sort of translation from one format to another, SAX is ideal.
  • establishing a context that lets you know when a JSON string has finished syntactically, without loading the whole thing into memory), you could look into event-based parsers (similar to what SAX does with XML).
  • Onlysentiment: 1
    1. general: 1
      • Thanks, I will have a look at simple.. details
  • Performance: 2
    1. general: 2
      • As it is designed for micro edition, it is really light-weight (small footprint) and IMHO really easy to use (much more easier than SAX/DOM etc.. details
      • SAX itself is very lightweight and fast, so I'm not sure why think it's too much.. details
  • Features: 5
    1. general: 5
      • Haha, so true.. details
      • I have 3 sections (named arrays) in some huge file.It successfully parses first (a tiny one, under 1000 bytes).. details
      • For one object in values I call nextObject.put.. details
      • Nothing special.. details
      • Thanks //edit Thanks for the responses so far :) The xml will be between 3/4 lines to about 50 max (at the extreme).. .. details
  • Bug: 1
    1. general: 1
      • It's not a JSON problem: it perfectly being mapped on iOS.. details
  • Usability: 29
    1. parsing: 1
      • It's like SAX parsing for XML.. details
    2. object: 1
      • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop.I had it going before but I cant find it again.. details
    3. tree: 1
      • Good point; maybe it's not so much for SAX, but SAX style (incremental processing, instead of tree model).. details
    4. nested: 1
      • Next array has nested array with simple objects (like this): CODESNIPPET_JAVA3 .. details
    5. json: 13
      • To prevent all the object creation, look at event driven xml and json handling like URL_http://www.saxproject.org/ [SAX] for XML and URL_http://code.google.com/p/json-simple/ [Json-Simple] and/or URL_http://jackson.codehaus.org/ [Jackson] for JSON.. details
      • It's not a JSON problem: it perfectly being mapped on iOS.. details
      • Most likely this will mean to use your own JSON tokenizer that does not build a full tree, but which is able to (like a SAX parser) only look at a part of the object tree at a time.. details
      • Use an XML parser like URL_http://www.saxproject.org/ [SAX] instead of a JSON parser.. details
      • So the ability to parse JSON using a SAX handler gives you an easy mechanism to build a DOM tree out of a JSON structure in Java.. details
      • The point of json is to not parse it like xml.. details
      • URL_http://code.google.com/p/json-simple/ [ URL_http://code.google.com/p/json-simple/ ] Stoppable SAX-like interface for streaming input of JSON text 2.. details
      • Is there a SaxParser that reads json and fires events so it looks like xml.. details
      • This would be great as it would allow my xml stuff to read json w/out any change except for the different sax parser.. details
      • There are several ways to parse JSON with it: Streaming (like Sax) Tree (like DOM) Object-mapped (like JAXB) EDIT: Take org.json classes, there are URL_http://developer.android.com/reference/org/json/package-summary.html [already-in] the android API.. details
      • EDIT 2** Maybe what you need is a "SAX like" JSON parser; e.g.. details
      • JSON is pretty simple to parse, and these tools tend to be pretty small so this shouldn't be a big deal.. details
      • You could also use XML pull here, which tends to be a little faster JSON: take a look at some of the open source JSON libraries and do some tweaking.. details
    6. translation: 1
      • For this sort of translation from one format to another, SAX is ideal.. details
    7. general: 11
      • currentParser.getCurrentName() is runs successfully and returns correct string, but currentParser.getText() fails.. details
      • It is basically like a chatty person telling you everything they are doing AS they do it.. details
      • Then you just pass that rule to the parser when you create it, like this: CODESNIPPET_JAVA2 .. details
      • And if you truly want SAX, writing wrapper from Stax to SAX is trivial as well (but not the other way around).. details
      • As it is designed for micro edition, it is really light-weight (small footprint) and IMHO really easy to use (much more easier than SAX/DOM etc.. details
      • The choice of SAX/DOM is really basde on what you're trying to parse, see this for how to decide on which one to use: URL_http://geekexplains.blogspot.com/2009/04/sax-vs-dom-differences-between- dom-and.html [ URL_http://geekexplains.blogspot.com/2009/04/sax-vs-dom-differences - between-dom-and.html] Even if you don't use SAX/DOM there are still simple options available to you, take a look at Simple : ) URL_http://simple.sourceforge.net/ [ URL_http://simple.sourceforge.net/ ] You may also want to consider STaX.. details
      • SAX itself is very lightweight and fast, so I'm not sure why think it's too much.. details
      • SAX is about the most efficient way possible to read XML in Java.. details
      • + Dom4j has SAX-like API but easier.. details
      • I suspect that by "lightweight", Joe means "is easy to use"; SAX' callback- oriented API is not the most user-friendly.. details
      • The SAX reader tells you what tags are seen and then gives the values for those tags.. details
  • Performance: 5
    1. general: 5
      • Yes, JSON does have a toXML and you can make JSON.XMLtoJSON, but i need to add extra bits, and change a few bits around to satisfy the dojo requirements.As the quick bursts will be very strict in format, and typically be 3/4 lines line (50 at the most a (a recurring set of 3/4 line elements) holding in memory will not be too much of an issue..Thanks again for the comments so far... details
      • Although JSON does seem less verbose (no closing tags for example), and is also provides a very easy means to pass data to Javascript, which is all the rage these days and hence probably one of the reasons for the big rise of JSON.. details
      • Also using a string buffer would actually be much less scalable** then using SAX because SAX doesn't require you to load the whole XML file into memory to use it.. details
      • If you have small files and you don't need to worry about performance, look into using the DOM.. details
      • Basically, under the covers I assume all HTML parsers will spin thru the string (or memory buffer) and parse, producing output on the way through.. details
  • Features: 1
    1. general: 1
      • If there is little translation then it may be extremely tiny.. details
  • Bug: 3
    1. general: 3
      • It's not an object or iterator creation problem: I can delete that where parser throws exception, but it will fail in the same place.. details
      • Jackson SAX parser throws exception when parsing huge JSON.. details
      • Basically, under the covers I assume all HTML parsers will spin thru the string (or memory buffer) and parse, producing output on the way through.. details
  • Usability: 17
    1. general: 1
      • If you have small files and you don't need to worry about performance, look into using the DOM.. details
    2. string: 1
      • Also using a string buffer would actually be much less scalable** then using SAX because SAX doesn't require you to load the whole XML file into memory to use it.. details
    3. object: 1
      • Plus, I have my own SAX utilities that add tag name based dispatch and an object stack which makes this stuff even more trivial sometimes.. details
    4. binding: 1
      • For example, there are many data binding tools for both XML and JSON; and using such tools could hide lower level details much better than using abstraction meant for one to process the other.. details
    5. parsing: 2
      • I spent more than a year working on this while writing a really robust Feed- parsing system that started off as a SAX-based system, then moved to STAX and the more I worked on it the more I realized how easily I could abstract out the pain of STAX with simple rules.. details
      • @PSpeed: IMHO SAX is not ideal, because event driven approach of SAX is harder to understand and use than pull parsing approach (of kXML parser or similar).. details
    6. json: 8
      • establishing a context that lets you know when a JSON string has finished syntactically, without loading the whole thing into memory), you could look into event-based parsers (similar to what SAX does with XML).. details
      • Yes, JSON does have a toXML and you can make JSON.XMLtoJSON, but i need to add extra bits, and change a few bits around to satisfy the dojo requirements.As the quick bursts will be very strict in format, and typically be 3/4 lines line (50 at the most a (a recurring set of 3/4 line elements) holding in memory will not be too much of an issue..Thanks again for the comments so far... details
      • Although JSON does seem less verbose (no closing tags for example), and is also provides a very easy means to pass data to Javascript, which is all the rage these days and hence probably one of the reasons for the big rise of JSON.. details
      • Yes, that is what I was trying to express : a single file big json array, and a single call for parsing, could seem easier, but could also mean loading everything in ram; while going "step by step" could you let handle entities one by one ... this is SAX against DOM again, but now that it is called JSON it makes it sound much more k00l.. details
      • If you're working with Perl its easy to turn a JSON string into a deep structure you can manipulate easily, but not so with Java.. details
      • I must agree with Falmarri, JSON != XML, and one should only result to emulation as last effort if nothing else works.However, maybe original asker wanted something LIKE sax API, not SAX API -- SAX API makes no sense since it's xml-specific; but push style approach is generic.But this all depends on whether question is specifically about SAX (simple api for XML, very xml specific), or about streaming/incremental parsing approach, which is more general.. details
      • However XML and JSON are different enough in structure that I really doubt you could have 100% code compatibility, to use XML-oriented SAX-processing code when consuming JSON.. details
      • Otherwise, reading JSON or XML is a little trickier, but not too bad I assume you already have some means of indexing the objects you want to merge into (like a Map of some sort) I assume you already have some means to know which property is the key that uniquely identifies an object (I assume last name is just to get the point across, as it would make a bad key) XML: For this type of use, I'd recommend a SAX reader for the xml - you'll need a stack to keep track of which objects you're adding data to.. details
    7. file: 2
      • If it's the size of the file you're worried about, then you should use the 'SAX' style example.. details
      • Java's implementation can be kind of annoying to use (You create a document by using a DocumentBuilder, which comes from a DocumentBuilderFactory) The code to create a document from a file looks like this: CODESNIPPET_JAVA1 .. details
    8. inputstream: 1
      • I tried to use BufferedInputStream with predefined block size instead of InputStream but it had no effect.. details