javascript - Shorten saved JSON object in browser URL -
currently i'm saving json object in url, once stringified , escaped escapedit get's extremly long:
example:
"%7b%22glossary%22%3a%7b%22title%22%3a%22example%20glossary%22%2c%22glossdiv%22%3a%7b%22title%22%3a%22s%22%2c%22glosslist%22%3a%7b%22glossentry%22%3a%7b%22id%22%3a%22sgml%22%2c%22sortas%22%3a%22sgml%22%2c%22glossterm%22%3a%22standard%20generalized%20markup%20language%22%2c%22acronym%22%3a%22sgml%22%2c%22abbrev%22%3a%22iso%208879%3a1986%22%2c%22glossdef%22%3a%7b%22para%22%3a%22a%20meta-markup%20language%2c%20used%20to%20create%20markup%20languages%20such%20as%20docbook.%22%2c%22glossseealso%22%3a%5b%22gml%22%2c%22xml%22%5d%7d%2c%22glosssee%22%3a%22markup%22%7d%7d%7d%7d%7d"
(object http://json.org/example.html) code:
var stringifeid = json.stringify({ "glossary": { "title": "example glossary", "glossdiv": { "title": "s", "glosslist": { "glossentry": { "id": "sgml", "sortas": "sgml", "glossterm": "standard generalized markup language", "acronym": "sgml", "abbrev": "iso 8879:1986", "glossdef": { "para": "a meta-markup language, used create markup languages such docbook.", "glossseealso": ["gml", "xml"] }, "glosssee": "markup" } } } } var encoded= encodeuricomponent(stringifeid ) "%7b%22glossary%22%3a%7b%22title%22%3a%22example%20glossary%22%2c%22glossdiv%22%3a%7b%22title%22%3a%22s%22%2c%22glosslist%22%3a%7b%22glossentry%22%3a%7b%22id%22%3a%22sgml%22%2c%22sortas%22%3a%22sgml%22%2c%22glossterm%22%3a%22standard%20generalized%20markup%20language%22%2c%22acronym%22%3a%22sgml%22%2c%22abbrev%22%3a%22iso%208879%3a1986%22%2c%22glossdef%22%3a%7b%22para%22%3a%22a%20meta-markup%20language%2c%20used%20to%20create%20markup%20languages%20such%20as%20docbook.%22%2c%22glossseealso%22%3a%5b%22gml%22%2c%22xml%22%5d%7d%2c%22glosssee%22%3a%22markup%22%7d%7d%7d%7d%7d"
is there way make shorter?
background: i'm having state based application in angular, uses routing , paramter save it's current state. state object stringified (json.stringify(..)
), when state changes throw browser back, etc, state taken form url, parsed backed , set in application. works fine, sooo long.
Comments
Post a Comment