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

use strict=False #18

Closed
lucemia opened this issue Oct 23, 2023 · 1 comment · Fixed by #20
Closed

use strict=False #18

lucemia opened this issue Oct 23, 2023 · 1 comment · Fixed by #20

Comments

@lucemia
Copy link
Contributor

lucemia commented Oct 23, 2023

from fuzzy_json.decoder import loads

test_case = '{"subject": "Introducing the Mandelic Acid and Allantoin Acne-Care Calming Ampoule", "body": "Dear valued client, \n\nWe are excited to announce the launch of our latest breakthrough product - the Mandelic Acid and Allantoin Acne-Care Calming Ampoule. This innovative serum is set to revolutionize the way we tackle acne, acne scars, and various skin concerns, delivering a transformative skincare experience like never before.\n\nAt MeiJia Beauty Co. Ltd., we are committed to providing high-quality skincare solutions that meet the diverse needs of our customers. The Mandelic Acid and Allantoin Acne-Care Calming Ampoule is the epitome of our dedication to excellence. This exceptional serum is meticulously formulated to target common skin issues and offer a comprehensive approach to achieving clear, radiant, and blemish-free skin.\n\nHarnessing the power of nature\'s finest ingredients, our ampoule combines mandelic acid and allantoin to ensure optimal results in addressing acne, acne scars, and uneven skin tone. With regular use, this ampoule whitens spots, smooths out acne scars, improves skin absorption rate, and provides a soothing and moisturizing effect. It is specially formulated to calm sensitive skin and relieve redness, making it suitable for all skin types.\n\nThe key ingredient, mandelic acid, has been scientifically proven to effectively improve the abnormality of hair follicle keratin, control sebum secretion, and combat metabolic acne. Additionally, allantoin, a powerful soothing agent, further enhances the efficacy of the ampoule, ensuring a truly transformative skincare experience.\n\nWe invite you to visit our official website at [insert contact info url] to learn more about the Mandelic Acid and Allantoin Acne-Care Calming Ampoule and its transformative benefits. Discover the power of this exceptional serum and unlock the secret to clear, radiant, and blemish-free skin.\n\nFor any media inquiries, please feel free to contact our spokesperson, 陳誠松, at [insert contact info email]. You can also find more information on our website at [insert contact info url].\n\nThank you for your continued support and trust in MeiJia Beauty Co. Ltd. We look forward to providing you with transformative skincare experiences.\n\nBest regards,\n[Your Name]\nMeiJia Beauty Co. Ltd."}'
result = loads(test_case, auto_repair=True)

這個 test case 還是沒過 我把 \n -> \\n 再跑一次就能過了

>>> json.loads('{"a": "\n"}', strict=False)
{'a': '\n'}

Originally posted by @lucemia in https://github.com/livingbio/gstudio/issues/13229#issuecomment-1774613945

@lucemia
Copy link
Contributor Author

lucemia commented Oct 23, 2023

If strict is false (True is the default), then control characters will be allowed inside strings. Control characters in this context are those with character codes in the 0–31 range, including '\t' (tab), '\n', '\r' and '\0'.

https://docs.python.org/3/library/json.html

lucemia added a commit that referenced this issue Oct 23, 2023
lucemia added a commit that referenced this issue Oct 23, 2023
* fix #18 use strict=False

* improve cov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant