java - JSON VS simple string manipulation to parse HttpRequest in Android -
i face common case of having extract information in remote server via httppost request. imagine in case of weather app retrieving weather info.
the server send long inputstream , interested in extracting information stream. keep in mind in memory-cpu bound environment.
we have 2 options:
1) use json or xml parser extract informations.
this recommended method, has disadvantages:
it painfully verbose, if want little information big stream.
it should faster , more garbage collection-friendly, i'm not sure case aforementioned case (little information big stream).
2) use simple string manipulation (ssm):
we reduce dimension of inputstream grossly trimming off useless infos, , extract informations compact string. purpose, can build filters using static methods, reduce work of garbage collector.
also method has disadvantages:
- i think method discouraged
- the more informations extract, slower method is. think there critical point in performance curve ssm becomes slower.
- it might less flexible json or other stock parser.
but important advantages:
- concise, human-readable code.
- it might difficult modify existing filter, easier create new one.
to sum up, question is:
1) simple string manipulation big no-no approach, or reasonable consider use? 2) if answered yes (big no-no approach) previous question, explain reason?
cheers :)
i request information in json format (not xml more verbose no advantage) , use event-based parser locate data wanted processing stream in line it's read server.
that easy on memory, , require no change in server delivers. far more reliable , resistant changes home-grown string slicing solution might put together.
i have freely distributed light-weight pull parser json on website. others available http://www.json.org.
Comments
Post a Comment