reyesoft / ngx-jsonapi

JSON API client library for Angular 5+ 👌 :: Production Ready 🚀
https://ngx-jsonapi.reyesoft.com/
MIT License
101 stars 52 forks source link

serialize and deserialize #247

Closed ehsan5 closed 5 years ago

ehsan5 commented 5 years ago

hi, I want to convert string to jsonapi object and resource,Can you help me?

maxi7587 commented 5 years ago

Hi @ehsan5 !

I would follow this steps:

  1. Use JSON.parse to convert the string to Object.
  2. Your Object (let's call it new_object) should satisfy IDocumentResource or ICacheableDocumentResource interfaces, so you can create a new resource (new_resource) of the desired type and use new_resource.fill(new_object).

This way, new_resource get's filled with the information from new_object.

Please tell me if this worked for you!