All Projects → rcdmk → Aspjson

rcdmk / Aspjson

Licence: mit
A fast classic ASP JSON parser and encoder for easy JSON manipulation to work with the new JavaScript MV* libraries and frameworks.

Projects that are alternatives of or similar to Aspjson

Yyjson
The fastest JSON library in C
Stars: ✭ 1,894 (+1047.88%)
Mutual labels:  json, serialization, deserialization
Pyjson tricks
Extra features for Python's JSON: comments, order, numpy, pandas, datetimes, and many more! Simple but customizable.
Stars: ✭ 131 (-20.61%)
Mutual labels:  json, serialization, deserialization
Jsonapi Rails
Rails gem for fast jsonapi-compliant APIs.
Stars: ✭ 242 (+46.67%)
Mutual labels:  json, serialization, deserialization
Dart Json Mapper
Serialize / Deserialize Dart Objects to / from JSON
Stars: ✭ 206 (+24.85%)
Mutual labels:  json, serialization, deserialization
Noproto
Flexible, Fast & Compact Serialization with RPC
Stars: ✭ 138 (-16.36%)
Mutual labels:  json, serialization, deserialization
Jsonapi Rb
Efficiently produce and consume JSON API documents.
Stars: ✭ 219 (+32.73%)
Mutual labels:  json, serialization, deserialization
Borer
Efficient CBOR and JSON (de)serialization in Scala
Stars: ✭ 131 (-20.61%)
Mutual labels:  json, serialization, deserialization
Mashumaro
Fast and well tested serialization framework on top of dataclasses
Stars: ✭ 208 (+26.06%)
Mutual labels:  json, serialization, deserialization
Jackson Module Kotlin
Module that adds support for serialization/deserialization of Kotlin (http://kotlinlang.org) classes and data classes.
Stars: ✭ 830 (+403.03%)
Mutual labels:  json, serialization, deserialization
Fastjson
A fast JSON parser/generator for Java.
Stars: ✭ 23,997 (+14443.64%)
Mutual labels:  json, serialization, deserialization
Dataclass factory
Modern way to convert python dataclasses or other objects to and from more common types like dicts or json-like structures
Stars: ✭ 116 (-29.7%)
Mutual labels:  json, serialization, deserialization
Java
jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
Stars: ✭ 1,308 (+692.73%)
Mutual labels:  json, serialization, deserialization
Bebop
An extremely simple, fast, efficient, cross-platform serialization format
Stars: ✭ 305 (+84.85%)
Mutual labels:  json, serialization, deserialization
Handyjson
A handy swift json-object serialization/deserialization library
Stars: ✭ 3,913 (+2271.52%)
Mutual labels:  json, serialization, deserialization
Go
A high-performance 100% compatible drop-in replacement of "encoding/json"
Stars: ✭ 10,248 (+6110.91%)
Mutual labels:  json, serialization, deserialization
Orjson
Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy
Stars: ✭ 2,595 (+1472.73%)
Mutual labels:  json, serialization, deserialization
Symfony Jsonapi
JSON API Transformer Bundle for Symfony 2 and Symfony 3
Stars: ✭ 114 (-30.91%)
Mutual labels:  json, serialization
Lora Serialization
LoraWAN serialization/deserialization library for The Things Network
Stars: ✭ 120 (-27.27%)
Mutual labels:  serialization, deserialization
Datafiles
A file-based ORM for Python dataclasses.
Stars: ✭ 113 (-31.52%)
Mutual labels:  json, serialization
Awesome Python Models
A curated list of awesome Python libraries, which implement models, schemas, serializers/deserializers, ODM's/ORM's, Active Records or similar patterns.
Stars: ✭ 124 (-24.85%)
Mutual labels:  serialization, deserialization

JSON object class 3.8.1

By RCDMK - rcdmk[at]hotmail[dot]com

Licence:

MIT license: http://opensource.org/licenses/mit-license.php
The MIT License (MIT)
Copyright (c) 2016 RCDMK - rcdmk[at]hotmail[dot]com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

How to use:

This lib requires LCID (Locale Code IDentifier) property of your ASP application before use. You can do this by setting the LCID in one of the following ways:

  • On the page declaration at the top of the page to set it to the entire page (eg.: <%@ LCID=1046 %>), OR
  • On the Session object to set it to all pages in the entire session (eg.: Session.LCID = 1046), OR
  • On the Response object, before using the class, to set it beyond this point on the page (eg.: Response.LCID = 1046)
Response.LCID = 1046 ' REQUIRED! Set your LCID here (1046 = Brazilian). Could also be the LCID property of the page declaration or the Session.LCID property

' instantiate the class
set JSON = New JSONobject

' add properties
JSON.Add "prop1", "someString"
JSON.Add "prop2", 12.3
JSON.Add "prop3", Array(1, 2, "three")

' remove properties
JSON.Remove "prop2"
JSON.Remove "thisDoesNotExistsAndWillDoNothing"

' change some values
JSON.Change "prop1", "someOtherString"
JSON.Change "prop4", "thisWillBeCreated" ' this property doen't exists and will be created automagically

' get the values
Response.Write JSON.Value("prop1") & "<br>"
Response.Write JSON.Value("prop2") & "<br>"
Response.Write JSON("prop3").Serialize() & "<br>" ' default function is equivalent to `.Value(propName)` - this property returns a JSONarray object
Response.Write JSON("prop4") & "<br>"

' get the JSON formatted output
Dim jsonString
jsonString = JSON.Serialize() ' this will contain the string representation of the JSON object

JSON.Write() ' this will write the output to the Response - equivalent to: Response.Write JSON.Serialize()

' load and parse some JSON formatted string
jsonString = "[{ ""strings"" : ""valorTexto"", ""numbers"": 123.456, ""arrays"": [1, ""2"", 3.4, [5, 6, [7, 8]]], ""objects"": { ""prop1"": ""outroTexto"", ""prop2"": [ { ""id"": 1, ""name"": ""item1"" }, { ""id"": 2, ""name"": ""item2"", ""teste"": { ""maisum"": [1, 2, 3] } } ] } }]" ' double double quotes here because of the VBScript quotes scaping

set oJSONoutput = JSON.Parse(jsonString) ' this method returns the parsed object. Arrays are parsed to JSONarray objects

JSON.Write() 		' outputs: '{"data":[{"strings":"valorTexto","numbers":123.456,"arrays":[1,"2",3.4,[5,6,[7,8]]],"objects":{"prop1":"outroTexto","prop2":[{"id":1,"name":"item1"},{"id":2,"name":"item2","teste":{"maisum":[1,2,3]}}]}}]}'
oJSONoutput.Write() ' outputs: '[{"strings":"valorTexto","numbers":123.456,"arrays":[1,"2",3.4,[5,6,[7,8]]],"objects":{"prop1":"outroTexto","prop2":[{"id":1,"name":"item1"},{"id":2,"name":"item2","teste":{"maisum":[1,2,3]}}]}}]'

' if the string represents an object (not an array of objects), the current object is returned so there is no need to set the return to a new variable
jsonString = "{ ""strings"" : ""valorTexto"", ""numbers"": 123.456, ""arrays"": [1, ""2"", 3.4, [5, 6, [7, 8]]] }"

JSON.Parse(jsonString)
JSON.Write() ' outputs: '{"strings":"valorTexto","numbers":123.456,"arrays":[1,"2",3.4,[5,6,[7,8]]]}'

To load records from a database:

' load records from an ADODB.Recordset
dim cn, rs
set cn = CreateObject("ADODB.Connection")
cn.Open "yourConnectionStringGoesHere"

set rs = cn.execute("SELECT id, nome, valor FROM pedidos ORDER BY id ASC")
' this could also be:
' set rs = CreateObject("ADODB.Recordset")
' rs.Open "SELECT id, nome, valor FROM pedidos ORDER BY id ASC", cn	

JSON.LoadRecordset rs
JSONarr.LoadRecordset rs

rs.Close
cn.Close
set rs = Nothing
set cn = Nothing

JSON.Write() 		' outputs: {"data":[{"id":1,"nome":"nome 1","valor":10.99},{"id":2,"nome":"nome 2","valor":19.1}]}
JSONarr.Write() 	' outputs: [{"id":1,"nome":"nome 1","valor":10.99},{"id":2,"nome":"nome 2","valor":19.1}]

To change the default property name ("data") when loading arrays and recordsets, use the defaultPropertyName property:

JSON.defaultPropertyName = "CustomName"
JSON.Write() 		' outputs: {"CustomName":[{"id":1,"nome":"nome 1","valor":10.99},{"id":2,"nome":"nome 2","valor":19.1}]}

If you want to use arrays, I have something for you too

' instantiate the class
Dim JSONarr = New JSONarray

' add something to the array
JSONarr.Push JSON 	' Can be JSON objects, and even JSON arrays
JSONarr.Push 1.25 	' Can be numbers
JSONarr.Push "and strings too"

' write to page
JSONarr.Write() ' Guess what? This does the same as the Write method from JSON object

To loop arrays you have to access the items property of the JSONarray object and you can also access the items trough its index:

dim i, item


' more readable loop
for each item in JSONarr.items
	if isObject(item) and typeName(item) = "JSONobject" then
		item.write()
	else
		response.write item
	end if
	
	response.write "<br>"
next


' faster but less readable
for i = 0 to JSONarr.length - 1
	if isObject(JSONarr(i)) then
		set item = JSONarr(i)
		
		if typeName(item) = "JSONobject" then
			item.write()
		else
			response.write item
		end if
	else
		item = JSONarr(i)
		response.write item
	end if
	
	response.write "<br>"
next
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].