Coder Social home page Coder Social logo

json_str's Introduction

json_str's People

Contributors

kodraus avatar waywardmonkeys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

json_str's Issues

Replacements

Take another look at supporting simple replacements for serde::Serialize values. They can just be spliced in line.

This means json_str will depend on serde, but that's not the end of the world.

This kind of thing will be important for building json strings that aren't purely constant data.

Escaped Strings

Make sure strings like "\"" are supported. Right now I suspect that will break the sanitiser because it'll hit the first " and not realise it's escaped within the string.

Cannot run binary built with json_str

cargo new --bin json-str-test
cd json-str-test
echo 'json_str = "*"' >> Cargo.toml
// main.rs
#[macro_use]
extern crate json_str;

fn main() {
    println!("Hello, world!");
}
cargo run
#   Compiling json-str-test v0.1.0 (file:///Users/mange/tmp/json-str-test)
#    Finished debug [unoptimized + debuginfo] target(s) in 0.10 secs
#     Running `target/debug/json-str-test`
# Hello, world!

rustup run stable ./target/debug/json-str-test
# Hello, world!

./target/debug/json-str-test
# dyld: Library not loaded: @rpath/libstd-f5a209a9.dylib
#  Referenced from: /Users/mange/tmp/json-str-test/./target/debug/json-str-test
#  Reason: image not found
# zsh: trace trap  ./target/debug/json-str-test

Removing the extern crate json_str, this problem does not appear.

> otool -L ./target/debug/json-str-test
./target/debug/json-str-test:
	/Users/mange/tmp/json-str-test/target/debug/deps/libjson_str-01e27c904eba6a7a.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libstd-f5a209a9.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

> uname -a
Darwin Naiad.local 14.5.0 Darwin Kernel Version 14.5.0: Sun Sep 25 22:07:15 PDT 2016; root:xnu-2782.50.9~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,3 Darwin

> rustc --version
rustc 1.14.0 (e8a012324 2016-12-16)

> rustup show
Default host: x86_64-apple-darwin

installed toolchains
--------------------

stable-x86_64-apple-darwin (default)
nightly-x86_64-apple-darwin

active toolchain
----------------

stable-x86_64-apple-darwin (default)
rustc 1.14.0 (e8a012324 2016-12-16)

> cargo --version
cargo 0.15.0-nightly (298a012 2016-12-20)

> cat Cargo.lock
[root]
name = "json-str-test"
version = "0.1.0"
dependencies = [
 "json_str 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "json_str"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"

[metadata]
"checksum json_str 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "73d699063dfc2ee05f524a9dc49a77906e675c90580f4b7551545328ed14b961"

Is there anything else I can help you with? Is there something I need to do? It feels like I should be able to run the built executable without having a Rust ecosystem installed.
This happens in release mode too.

Use proper parsers

This library is using a kind of home-grown sanitising parser. That was ok when it was simple but it's getting a bit more complex now.

For future maintainability, and potential performance improvements, we should replace the parser with something like nom.

Refactor nightly json_fn impl

The current json_fn impl on nightly could be much clearer. The various bits could be split into separate methods so it's more obvious what's going on.

There could also be a way to parse just the set of closure arguments using the Parser instead of doing it manually.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.