0

I need to create a new content type in orchard cms that will only have a field indicating a json url to be consumed. My question is how to consume json in content-type and return the data consumed. Thanks

Luiz Alegria
  • 197
  • 3
  • 18

1 Answers1

1

You need to issue a web request using eg. RestSharp (or built-in WebClient class) and return deserialized data. RestSharp already has a JSON deserializer built-in, but if you need more robust solution you can use JSON.NET.

The request would be best done in one of the content part handler events (eg. OnLoaded) - just set a value of some property on your custom part to the returned data from there.

Community
  • 1
  • 1
Piotr Szmyd
  • 13,371
  • 6
  • 44
  • 61