B4J Question JSON Manage Data

PatrikCavina

Active Member
Licensed User
Longtime User
Hi to all,
I've started to do a little project using JSON string.
Simply i call api from web service, passing an IP Address, and it returns me a json response containing informations about the sended IP.
So i want to know what is the best approch to manipulate information from json response (I know the existence of JSONParser and i know how to use it).
For now i thinked three way to do this:
  1. Create a class (or CostumClass) for each object inside the JSON response and using a master Class for assign each object inside JSON Text to the correct class (Maybe with select case innested in for loop where i slide keys of map and recursivly calls this 'sub' for each object inside an another object);
  2. Create one class that get the entire json string, get parsing it and using specific methods to get data i want from this "general class" that implement all informations;
  3. Create one class not related completely to parsing json but that can have other methods relative to class that rappressent, so data are taken and used from Map.GetKey() if necessary.
For you what are advantages and disadvantages of each method i've indicated?

My purpose in this case, in addition to writing an application that given an ip address returns the related information, is to write a library for B4J.
So I thought of method 1.
I hope I was clear in explaining my doubt.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…