Running this code slightly more than half of the integers can be parsed to json. I'm looking to understand the why here, let's assume I know nothing about encoding.

ruby 2.5.1

(1..1000).each do |i|
  begin
    Marshal.dump(i).to_json
    puts i
  rescue => e
    puts "#{i} #{e.message}"
  end
end


756"\xF4" from ASCII-8BIT to UTF-8
757"\xF5" from ASCII-8BIT to UTF-8
758"\xF6" from ASCII-8BIT to UTF-8
759"\xF7" from ASCII-8BIT to UTF-8
760"\xF8" from ASCII-8BIT to UTF-8
761"\xF9" from ASCII-8BIT to UTF-8
762"\xFA" from ASCII-8BIT to UTF-8
763"\xFB" from ASCII-8BIT to UTF-8
764"\xFC" from ASCII-8BIT to UTF-8
765"\xFD" from ASCII-8BIT to UTF-8
766"\xFE" from ASCII-8BIT to UTF-8
767"\xFF" from ASCII-8BIT to UTF-8
768
769
770
771
772
773
774
775
776
777

0 Answers