Nested Query String Encoder/Decoder c#

397 Views Asked by At

Brief

I'm trying to call some API endpoints who use nested query strings in the GET calls

Issue

Trying not to reinvent the wheel, I'm looking for a library that is able to convert a nested object into query string parameters

Example

Given the object:

{'searchCriteria':{'filterGroups':[{'filters':[{'field':'entity_id','value':"1",'condition_type':'eq'}]}]}}

Results into a URL on the likes of: http://example.com/rest/V1/products?searchCriteria[filterGroups][0][filters][0][field]=entity_id&searchCriteria[filterGroups][0][filters][0][condition_type]=eq&searchCriteria[filterGroups][0][filters][0][value]=5325

or, when expanded:

searchCriteria[filterGroups][0][filters][0][field]=entity_id
searchCriteria[filterGroups][0][filters][0][condition_type]=eq
searchCriteria[filterGroups][0][filters][0][value]=5325

Resources

Equivalent nodejs library: https://www.npmjs.com/package/qs

Recap

How do you serialise/deserialise a nested query string?

0

There are 0 best solutions below