Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #125 fix trailing comma #126

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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架構,聯繫員工了解團隊文化。",}
Loading