Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

This is a follow-up to "Json String Parsing"

This is a follow-up to "Json String Parsing"

Notice removed Authoritative reference needed by Lin Ma
Bounty Ended with Tersosauros's answer chosen by Lin Ma
Tweeted twitter.com/StackCodeReview/status/708634211729670146
Rollback to Revision 3
Source Link
Quill
  • 12k
  • 5
  • 41
  • 93

Improved version of code based state machine, based on guidance from Tersosauros,

status = READY
result={}
READY_SM = {""":STRING, ":":COLON, ",":COMMA}
NUMBER="0123456789."
for c in str1:
 if state == READY:
 if c in NOP:
 continue
 elif c in NUMBERS:
 state = NUMBER
 elif c in READY_SM.keys():
 state = READY_SM[c]
 if state == COLON:
 tempKey = temp
 temp = ""
 statue = READY
 if state == COMMA:
 result[tempKey]=temp
 temp=""
 state=READY
 if state == STRING:
 if c == '""':
 state = READY
 else:
 temp += c
 if state == NUMBER:
 if c == ','
 result[tempKey]=temp
 temp=""
 state=READY
 elif c in NOP:
 continue
 else:
 temp += c
return result

Improved version of code based state machine, based on guidance from Tersosauros,

status = READY
result={}
READY_SM = {""":STRING, ":":COLON, ",":COMMA}
NUMBER="0123456789."
for c in str1:
 if state == READY:
 if c in NOP:
 continue
 elif c in NUMBERS:
 state = NUMBER
 elif c in READY_SM.keys():
 state = READY_SM[c]
 if state == COLON:
 tempKey = temp
 temp = ""
 statue = READY
 if state == COMMA:
 result[tempKey]=temp
 temp=""
 state=READY
 if state == STRING:
 if c == '""':
 state = READY
 else:
 temp += c
 if state == NUMBER:
 if c == ','
 result[tempKey]=temp
 temp=""
 state=READY
 elif c in NOP:
 continue
 else:
 temp += c
return result
added 36 characters in body
Source Link
Lin Ma
  • 3.5k
  • 3
  • 33
  • 57

Improved version of code based state machine, based on guidance from Tersosauros,

Improved version of code based state machine,

Improved version of code based state machine, based on guidance from Tersosauros,

added 901 characters in body
Source Link
Lin Ma
  • 3.5k
  • 3
  • 33
  • 57
Loading
Notice added Authoritative reference needed by Lin Ma
Bounty Started worth 50 reputation by Lin Ma
deleted 193 characters in body; edited tags; edited title
Source Link
Vogel612
  • 25.5k
  • 7
  • 59
  • 141
Loading
added 15 characters in body
Source Link
Lin Ma
  • 3.5k
  • 3
  • 33
  • 57
Loading
Source Link
Lin Ma
  • 3.5k
  • 3
  • 33
  • 57
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /