Java JSON serialization deserialization example

From , 4 Years ago, written in Java, viewed 54 times.
URL https://pastebin.vip/view/ac52c626
  1.   package json;
  2.    
  3.     import java.io.StringReader;
  4.    
  5.     import java.util.Date;
  6.    
  7.     import antlr.RecognitionException;
  8.    
  9.     import antlr.TokenStreamException;
  10.    
  11.     import com.sdicons.json.mapper.JSONMapper;
  12.    
  13.     import com.sdicons.json.mapper.MapperException;
  14.    
  15.     import com.sdicons.json.model.JSONValue;
  16.    
  17.     import com.sdicons.json.parser.JSONParser;
  18.    
  19.     public class JsonSerialize {
  20.    
  21.     /**
  22.    
  23.     * @param args
  24.    
  25.     * @throws MapperException
  26.    
  27.     * @throws RecognitionException
  28.    
  29.     * @throws TokenStreamException
  30.    
  31.     */
  32.    
  33.     public static void main(String[] args) throws MapperException, TokenStreamException, RecognitionException {
  34.    
  35.     JSONValue jsonValue = JSONMapper.toJSONnew Date());
  36.    
  37.     String jsonStr = jsonValue.rendertrue);
  38.    
  39.     System.out.println(jsonStr);
  40.    
  41.     JSONParser parser = new JSONParser(new StringReader(jsonStr));
  42.    
  43.     Date date =Date) JSONMapper.toJava(parser.nextValue(), Date.class);
  44.    
  45.     System.out.println(date);
  46.    
  47.     }
  48.    
  49.     }
  50. //java/4483

Reply to "Java JSON serialization deserialization example"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website