项目作者: xlmnxp

项目描述 :
Json Deserializer for Alusus Language
高级语言:
项目地址: git://github.com/xlmnxp/Json.git
创建时间: 2020-01-02T15:11:39Z
项目社区:https://github.com/xlmnxp/Json

开源协议:MIT License

下载


Json

Json Deserializer for Alusus Language

How to Import

  1. import "Srl/Console.alusus"
  2. import "Apm.alusus"
  3. Apm.importFile("xlmnxp/Json");
  4. def jsonObject: Json = "{\"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 to create markup languages such as DocBook.\",\"GlossSeeAlso\": [\"GML\", \"XML\"]}, \"GlossSee\": \"markup\"}}}}}";
  5. Srl.Console.print(jsonObject.getObject("glossary").getObject("GlossDiv").getObject("GlossList").getObject("GlossEntry").getObject("GlossDef").getObject("GlossSeeAlso").getString(1)); // output: XML

Handlers

  • Json~init(str: ptr[Array[Char]])
    1. initialize Type with parse JSON from String

Methods

  • Json.get(key: ptr[Array[Char]]): String
    1. return value of key as String with Quotations
  • Json.get(key: Int): String

    1. return value of index as String with Quotations
  • Json.getString(key: ptr[Array[Char]]): String

    1. return value of key as String without Quotations
  • Json.getString(key: Int): String

    1. return value of index as String without Quotations
  • Json.getInt(key: ptr[Array[Char]]): Int

    1. return value of key as Int
  • Json.getInt(key: Int): Int

    1. return value of index as Int
  • Json.getFloat(key: ptr[Array[Char]]): Float

    1. return value of key as Float
  • Json.getFloat(key: Int): Float

    1. return value of index as Float
  • Json.getBool(key: ptr[Array[Char]]): Bool

    1. return value of key as Boolean
  • Json.getBool(key: Int): Bool

    1. return value of index as Boolean
  • Json.getObject(key: ptr[Array[Char]]): Json

    1. return value of key as new Json
  • Json.getObject(key: Int): Json

    1. return value of index as new Json
  • Json.isObject(): Bool

    1. return true only when json is Object
  • Json.isArray(): Bool
    1. return true only when json is Array
  • Json.getLength(): Int

    1. return length of Children
  • Json.hasQuotes(stringWithQuotes: String): Bool

Operators

  • this = ptr[array[Char]]]
    1. def jsonObject: Json = "{lang: 'alusus'}"
  • this = String
    1. def str: String = "{lang: 'alusus'}"
    2. def jsonObject: Json = str

LICENSE

MIT LICENSE.