Giter VIP home page Giter VIP logo

jsxrecord's Introduction

Test Dialyzer DocsGitHub release Crowdin Join the chat at https://gitter.im/zotonic/zotonic

Zotonic

Zotonic is the open source, high speed, real-time web framework and content management system, built with Erlang.

It is flexible, extensible and designed from the ground up to support dynamic, interactive websites and mobile solutions.

Zotonic is incredibly fast and wonderfully stable – suited for anything from basic websites to complex distributed applications. It offers an elegant backend for managing content with the flexibility that developers need to build truly amazing applications.

Installation

Documentation

You can find out more about Zotonic on http://zotonic.com, including:

Contributing

Zotonic is an open source project, made possible by the community. If you’d like to contribute, please read the Contributing chapter in the documentation.

If you encounter any issues, please report them in our issue tracker. If you discover any security-related issues, please contact us at [email protected].

License

Zotonic is released under the Apache 2.0 License. Please refer to the included LICENSE file for more information.

Thanks

Thanks to the following services for supporting Open Source:

jsxrecord's People

Contributors

mmzeeman avatar mworrell avatar williamthome avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jsxrecord's Issues

Bad argument encoding tuple

I'm facing an issue sending a post request to a Zotonic model.
My post URL is https://mysite:8443/api/model/mymodel/post/foo and the body is an empty JSON.
This is the Resp value in controller_api:process_done:3, line 173:

#{<<"result">> =>
           {#{payload => #{},
              properties =>
                  #{content_type => {<<"application">>,<<"json">>,[]},
                    response_topic =>
                        [<<"reply">>,<<"call-YVLe49c3HZCSSN:fP5wC">>,<<"1">>]},
              qos => 0,retain => false,
              topic =>
                  [<<"model">>,<<"mymodel">>,<<"post">>,<<"foo">>],
              type => publish},
            []},
       <<"status">> => <<"ok">>}

If I change all tuples to list the jsxrecord:encode/1 encodes the value without errors.
To simulate this issue just do this:

jsxrecord:encode({}).
** exception error: bad argument
     in function  jsx_parser:value/4 (/home/williamthome/devel/zotonic/_build/default/lib/jsx/src/jsx_parser.erl, line 163)

UPDATE:

Note: The request was made via an external API.

Bug encoding a list of dates

There is a bug when jsxrecord:encode/1 receives a list of dates as the argument.

To reproduce:

jsxrecord:encode([{{2023,10,3},{0,0,0}},{{2023,10,4},{0,0,0}}]).

The error is:

** exception error: bad argument
     in function  jsx_encoder:unzip/2 (/home/williamthome/devel/zotonic_sl/_build/default/lib/jsx/src/jsx_encoder.erl, line 65)
     in call from jsx_encoder:encode_/2 (/home/williamthome/devel/zotonic_sl/_build/default/lib/jsx/src/jsx_encoder.erl, line 55)
     in call from jsx_encoder:unpack/3 (/home/williamthome/devel/zotonic_sl/_build/default/lib/jsx/src/jsx_encoder.erl, line 75)
     in call from jsx_encoder:encode/2 (/home/williamthome/devel/zotonic_sl/_build/default/lib/jsx/src/jsx_encoder.erl, line 45)
     in call from jsx_encoder:'-encoder/3-fun-0-'/2 (/home/williamthome/devel/zotonic_sl/_build/default/lib/jsx/src/jsx_encoder.erl, line 32)

The problem is in the function expand_records/1, line 229 of the jsxrecord module.
The pattern match is ({K, V}) -> {K, expand_records(V)};, but this can be a date. Changing this line to ({K, V}) when is_binary(K) -> {K, expand_records(V)}; fixes the bug, but I don't know if just binary() is expected as the type for the proplists key.

EDIT

but I don't know if just binary() is expected as the type for the proplists key.

The decode/1 function considers keys as binaries by the make_proplist/1 function.

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.