소스 검색

Merge 2f405e2b9a into b403e4ab5b

pull/85/merge
Joe DeVivo 10 년 전
부모
커밋
5da0442288
3개의 변경된 파일58개의 추가작업 그리고 6개의 파일을 삭제
  1. +1
    -0
      .gitignore
  2. +25
    -2
      Makefile
  3. +32
    -4
      src/jiffy.erl

+ 1
- 0
.gitignore 파일 보기

@ -6,3 +6,4 @@
.eunit
deps
erln8.config
jiffy.plt

+ 25
- 2
Makefile 파일 보기

@ -29,15 +29,38 @@ build: depends
$(REBAR) compile
eunit:
eunit: build
$(REBAR) eunit skip_deps=true
check: build eunit
check: build eunit dialyzer
%.beam: %.erl
erlc -o test/ $<
DIALYZER = dialyzer
DIALYZER_OPTS ?=
JIFFY_PLT = jiffy.plt
ERLANG_DIALYZER_APPS ?= asn1 \
compiler \
crypto \
edoc \
erts \
inets \
kernel \
mnesia \
public_key \
ssl \
stdlib \
syntax_tools \
tools \
xmerl
$(JIFFY_PLT):
@echo "Missing $(JIFFY_PLT). Please wait while a new PLT is compiled."
$(DIALYZER) --build_plt --apps $(ERLANG_DIALYZER_APPS) --output_plt $(JIFFY_PLT)
dialyzer: $(JIFFY_PLT) build
@$(DIALYZER) $(DIALYZER_OPTS) --plts $(JIFFY_PLT) -r ebin
.PHONY: all clean distclean depends build etap eunit check

+ 32
- 4
src/jiffy.erl 파일 보기

@ -5,13 +5,41 @@
-export([decode/1, decode/2, encode/1, encode/2]).
-define(NOT_LOADED, not_loaded(?LINE)).
-on_load(init/0).
%% More information on the JSON standard: http://json.org
-type json_value() :: null
| true
| false
| json_string()
| json_number()
| json_object()
| json_array().
-type json_array() :: [json_value()].
-type json_string() :: binary().
-type json_number() :: integer() | float().
-type json_object() :: {[{json_string(),json_value()}]}.
-type decode_option() :: return_maps
| {bytes_per_iter, non_neg_integer()}.
-type decode_options() :: [decode_option()].
-type encode_option() :: unescape
| pretty
| force_utf8
| {bytes_per_iter, non_neg_integer()}.
-type encode_options() :: [encode_option()].
-export_type([json_value/0]).
-on_load(init/0).
-spec decode(iolist() | binary()) -> json_value().
decode(Data) ->
decode(Data, []).
-spec decode(iolist() | binary(), decode_options()) -> json_value().
decode(Data, Opts) when is_binary(Data), is_list(Opts) ->
case nif_decode_init(Data, Opts) of
{error, _} = Error ->
@ -26,11 +54,11 @@ decode(Data, Opts) when is_binary(Data), is_list(Opts) ->
decode(Data, Opts) when is_list(Data) ->
decode(iolist_to_binary(Data), Opts).
-spec encode(json_value()) -> iolist().
encode(Data) ->
encode(Data, []).
-spec encode(json_value(), encode_options()) -> iolist().
encode(Data, Options) ->
ForceUTF8 = lists:member(force_utf8, Options),
case nif_encode_init(Data, Options) of

불러오는 중...
취소
저장