Comments (3)
json
has no particular handling for ASCII-8BIT, it just calls encode
for anything that's not UTF-8. For a library, using force_encoding
on binary strings is a rather dangerous assumption, and a senseless operation on any other encoding.
from json.
Ok, i admit I am not an expert when it comes to encoding but it seemed strange to me because the first thing that is done after that step is utf8_to_json or utf9_to_json_ascii which calls ".force_encoding(::Encoding::ASCII_8BIT)" on the string. it seems very odd to force it ahead of time to UTF8 just to force it back to ascci-8bit, why couldn't it leave it as 8bit? since thats more of what it wants to be anyways?
from json.
I stand corrected: json does check for binary strings, and tries to detect its encoding (defaulting to UTF-8, see here). The problem here is that this string is stll not a valid UTF-8 sequence, and json is strict in parsing its input.
from json.
Related Issues (20)
- Version 2.6 breaking changes (& changelog deletion?)
- 2.6.0 and tagging releases going forward? HOT 1
- wrong number of arguments (given 2, expected 1) (ArgumentError) HOT 1
- Segmentation fault in ruby 3.0.4 HOT 4
- Version 2.6.2 Jruby Fails to build gem native extension HOT 3
- /usr/lib64/libjemalloc.so.2: cannot allocate memory in static TLS block
- Is it possible to override the format used when printing a Timestamp?
- IPAddr#to_json remove prefix address with CIDR
- gem install generates wrong json-2.6.2.gemspec file HOT 7
- JSON gem is slow parsing integers/floats when there's multiple threads executing at once (in Ractors) HOT 1
- Hilarious surrogate(?) bug
- JSON.pretty_generate generates wrong format json output to MRI for at least an empty hash version 9.4.0.0 HOT 4
- JRuby extension fails to build on Windows HOT 1
- How to use both, pure and ext variant
- Streaming enhancements for dumping
- Behaviour change between 2.5.1 and 2.6.0
- Test
- JSON.parse Alters Encoding of Passed String Unexpectedly
- Shorten reference to input data in error message
- json-1.8.6/lib/json/common.rb:155:in `initialize': wrong number of arguments (given 2, expected 1) (ArgumentError) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json.