Opened 7 years ago

Closed 6 years ago

#11577 closed enhancement (implemented)

Use Gson to format/parse documents rather than StringBuilder/Scanner

Reported by: karsten Owned by: karsten
Priority: Medium Milestone:
Component: Metrics/Onionoo Version:
Severity: Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


Except for unit tests, we're formatting and parsing JSON documents ourselves using classes like StringBuilder and Scanner. This was the quickest way for me to produce a running prototype back in 2011, and it scaled surprisingly well. But there are several reasons for finally switching to a JSON library: less code, fewer bugs, and potentially better performance. The most recent hack for #11350 made me think that we finally have to switch to Gson for formatting and parsing all our JSON documents.

The following classes should be (de-)serialized using Gson:

  • UptimeDocument
  • ClientsDocument
  • WeightsDocument
  • BandwidthDocument
  • DetailsDocument
  • DetailsStatus

Child Tickets

Change History (4)

comment:1 Changed 7 years ago by karsten

Status: newneeds_review

Pushed branch task-11577 to my public repository which uses Gson to format the first four classes UptimeDocument, ClientsDocument, WeightsDocument, and BandwidthDocument. These changes are relatively easy, because they only contain ASCII characters.

Review much appreciated!

DetailsDocument and DetailsStatus will be more difficult, because they may contain UTF-8 characters in platform lines, contact information, city names, and so on. Previously, we used to escape any non-ASCII character, but Gson writes UTF-8 and assumes UTF-8 when reading. The biggest issue here will be transition from existing documents.

comment:2 Changed 7 years ago by karsten

Pushed four more commits to my task-11577 branch. These changes now also use Gson to (de-)serialize DetailsStatus and DetailsDocument. As a bonus, I made the evil hack for #11350 slightly less evil. This is all untested code that may break horribly.

Review much appreciated!

comment:3 Changed 6 years ago by karsten

Rebased the branch above and squashed fixes in order to have a clean commit series. New branch is task-11577-2 in my public repository.

comment:4 Changed 6 years ago by karsten

Resolution: implemented
Status: needs_reviewclosed

Merged into master and deployed on yatei. Closing.

Note: See TracTickets for help on using tickets.