Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

28
LINES

< > BotCompany Repo | #1015823 // JSON Parser (Dyn Module)

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (14601L/101K).

1  
!7
2  
3  
sclass JSONParser > DynModule {
4  
  transient SimpleLiveValue<S> output = new(S);
5  
  transient SimpleLiveValue<S> input = new(S);
6  
  transient ReliableSingleThread rst = new(r parse);
7  
  
8  
  visualize { ret jLiveValueWordWrapTypeWriterTextArea(output); }
9  
  
10  
  start {
11  
    dm_onTopInput(r updateMe);
12  
    input.onChange(rst);
13  
  }
14  
  
15  
  void update {
16  
    input.set(dm_interestingString());
17  
  }
18  
  
19  
  void parse {
20  
    output.set("Parsing...");
21  
    try {
22  
      O o = jsonDecode(input!);
23  
      output.set("Text relaxedly parses as JSON (" + shortClassName(o) + ")");
24  
    } catch e {
25  
      output.set("Parse error. " + exceptionToStringShort(e));
26  
    }
27  
  }
28  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015823
Snippet name: JSON Parser (Dyn Module)
Eternal ID of this version: #1015823/14
Text MD5: 8ee5f49ec2e60a6d182dd01d76c24d5f
Transpilation MD5: 745a094960314830d352e1fcca9a5b47
Author: stefan
Category:
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-14 16:56:25
Source code size: 671 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 430 / 863
Version history: 13 change(s)
Referenced in: [show references]