Skip to content

Commit

Permalink
fix #125 fix trailing comma
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemia committed Jun 24, 2024
1 parent 6cefe72 commit b9450dd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/fuzzy_json/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def state_post_value(input: str, stack: list[str]) -> str | None:
return state_finish(input, stack)

if input[0] == ",":
# NOTE: assume there is a trailing comma
if input[1] in {"}", "]"}:
return state_post_value(input[1:], stack)
if stack[-1] == "[":
return input[0] + state_value(input[1:], stack)
if stack[-1] == "{":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"longer_summary": "AI熱潮延燒超過一年,輝達股價居高不下。一名印度軟體工程師分享了如何獲得輝達工作,薪酬詳細說明。他以應屆畢業生身份加入輝達,底薪160萬盧比,股票期貨250萬盧比,表現好可獲得額外股票獎勵。升遷後底薪超過200萬盧比,他認為輝達工作有更多成長機會,能發揮更大影響力。輝達文化寬容失敗,工程師職稱分為8個層級。面試時需準備數據結構和演算法問題,使用STAR架構,聯繫員工了解團隊文化。"
}
1 change: 1 addition & 0 deletions src/fuzzy_json/tests/test_data/invalid/case8.jsonx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"longer_summary":"AI熱潮延燒超過一年,輝達股價居高不下。一名印度軟體工程師分享了如何獲得輝達工作,薪酬詳細說明。他以應屆畢業生身份加入輝達,底薪160萬盧比,股票期貨250萬盧比,表現好可獲得額外股票獎勵。升遷後底薪超過200萬盧比,他認為輝達工作有更多成長機會,能發揮更大影響力。輝達文化寬容失敗,工程師職稱分為8個層級。面試時需準備數據結構和演算法問題,使用STAR架構,聯繫員工了解團隊文化。",}

0 comments on commit b9450dd

Please sign in to comment.