Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrderHistory - Fatal error in JsonConvert. Failed to map the JSON object to the JavaScript class "OrderData" because of a type error. #15

Open
AndrewBarba opened this issue Jul 24, 2018 · 3 comments

Comments

@AndrewBarba
Copy link

AndrewBarba commented Jul 24, 2018

Seeing this error when listing certain markets:

  pathname: '/account/getorderhistory',
  data: { market: 'BTC-NEO' },
  error: Error: Fatal error in JsonConvert. Failed to map the JSON object to the JavaScript class "OrderData" because of a type error.

	Class property:
		OrderType

	Expected type:
		undefined

	JSON property:
		OrderType

	JSON type:
		string

	JSON value:
		"LIMIT_BUY"

	Reason: Expected type is unknown. There might be multiple reasons for this:
	- You are missing the decorator @JsonObject (for object mapping)
	- You are missing the decorator @JsonConverter (for custom mapping) before your class definition
	- Your given class is undefined in the decorator because of circular dependencies


    at JsonConvert.deserializeObject_loopProperty (/api/node_modules/json2typescript/src/json2typescript/json-convert.js:220:19)
    at JsonConvert.deserializeObject (/api/node_modules/json2typescript/src/json2typescript/json-convert.js:132:18)
    at JsonConvert.deserializeArray /api/node_modules/json2typescript/src/json2typescript/json-convert.js:157:29)
    at JsonConvert.deserialize (/api/node_modules/json2typescript/src/json2typescript/json-convert.js:109:25)
    at Promise (/api/node_modules/bittrex-typescript/src/Transport.js:43:53)
    at new Promise (<anonymous>)
    at Transport.handleResponse (/api/node_modules/bittrex-typescript/src/Transport.js:39:16)
    at got.then (/api/node_modules/bittrex-typescript/src/Transport.js:29:25)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7) }

Any ideas? The response looks totally normal, every OrderType is either LIMIT_BUY or LIMIT_SELL

@lookfirst
Copy link
Owner

Hi @AndrewBarba,

Thanks for the report. It seems to be an issue with the deserialization. Looking at the code though, it seems like that property is there:

https://github.com/lookfirst/bittrex-typescript/blob/master/src/model/OrderData.ts#L15

I am at a bit of a loss myself!

@AndrewBarba
Copy link
Author

AndrewBarba commented Jul 25, 2018

Yeah really strange, I've never used a mapper like this before. This line confused me:

@JsonProperty('OrderType', undefined, true)

That undefined seems strange, I feel like it should be String, but I don't really know...

@lookfirst
Copy link
Owner

The mappers save a lot of typing for populating models with raw json data. They also help in catching errors like this. If bittrex changes their api randomly, you want your code to fail fast and with an error.

You are probably correct. Looks like a copy/paste error. Can you edit the code in your node_modules folder and try it as String? If that works, submit a PR and I'll merge it straight in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants