-
Notifications
You must be signed in to change notification settings - Fork 820
PackedArray::fromJSON() and toJSON methods #3806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1d4133c
PackedArray::fromJSON() and toJSON methods
jmikola 6c3e381
Remove trailing commas from Document toJSON examples
jmikola 3e305b8
Remove blank lines
jmikola cc5d523
Add returnvalues sections for Document and PackedArray from/to methods
jmikola cfb5417
Clarify errors for Document and PackedArray fromJSON() methods
jmikola File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- $Revision$ --> | ||
<refentry xml:id="mongodb-bson-packedarray.fromjson" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<refnamediv> | ||
<refname>MongoDB\BSON\PackedArray::fromJSON</refname> | ||
<refpurpose>Construct a new BSON array instance from a JSON string</refpurpose> | ||
</refnamediv> | ||
|
||
<refsect1 role="description"> | ||
&reftitle.description; | ||
<methodsynopsis> | ||
<modifier>final</modifier> <modifier>static</modifier> <modifier>public</modifier> <type>MongoDB\BSON\PackedArray</type><methodname>MongoDB\BSON\PackedArray::fromJSON</methodname> | ||
<methodparam><type>string</type><parameter>json</parameter></methodparam> | ||
</methodsynopsis> | ||
<para> | ||
Converts an | ||
<link xlink:href="&url.mongodb.docs.extendedjson;">extended JSON</link> | ||
string to its BSON representation. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="parameters"> | ||
&reftitle.parameters; | ||
<variablelist> | ||
<varlistentry> | ||
<term><parameter>json</parameter> (<type>string</type>)</term> | ||
<listitem> | ||
<para> | ||
JSON value to be converted. | ||
</para> | ||
</listitem> | ||
</varlistentry> | ||
</variablelist> | ||
</refsect1> | ||
|
||
<refsect1 role="returnvalues"> | ||
&reftitle.returnvalues; | ||
<para> | ||
Returns a new <classname>MongoDB\BSON\PackedArray</classname> instance. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="errors"> | ||
&reftitle.errors; | ||
<simplelist> | ||
&mongodb.throws.argumentparsing; | ||
<member> | ||
Throws | ||
<classname>MongoDB\Driver\Exception\UnexpectedValueException</classname> if | ||
the JSON value cannot be converted to a BSON array (e.g. due to a syntax | ||
error). | ||
</member> | ||
</simplelist> | ||
</refsect1> | ||
|
||
<refsect1 role="examples"> | ||
&reftitle.examples; | ||
<example> | ||
<title><methodname>MongoDB\BSON\PackedArray::fromJSON</methodname> example</title> | ||
<programlisting role="php"> | ||
<![CDATA[ | ||
<?php | ||
$json = '[ "foo", { "$numberInt" : "123" }, { "$numberLong" : "4294967295" }, { "$oid" : "56315a7c6118fd1b920270b1" } ]'; | ||
$packedArray = MongoDB\BSON\PackedArray::fromJSON($json); | ||
var_dump($packedArray); | ||
?> | ||
]]> | ||
</programlisting> | ||
&example.outputs; | ||
<screen> | ||
<![CDATA[ | ||
object(MongoDB\BSON\PackedArray)#1 (2) { | ||
["data"]=> | ||
string(68) "MQAAAAIwAAQAAABmb28AEDEAewAAABIyAP////8AAAAABzMAVjFafGEY/RuSAnCxAA==" | ||
["value"]=> | ||
array(4) { | ||
[0]=> | ||
string(3) "foo" | ||
[1]=> | ||
int(123) | ||
[2]=> | ||
int(4294967295) | ||
[3]=> | ||
object(MongoDB\BSON\ObjectId)#2 (1) { | ||
["oid"]=> | ||
string(24) "56315a7c6118fd1b920270b1" | ||
} | ||
} | ||
} | ||
]]> | ||
</screen> | ||
</example> | ||
</refsect1> | ||
|
||
<refsect1 role="seealso"> | ||
&reftitle.seealso; | ||
<simplelist> | ||
<member><methodname>MongoDB\BSON\PackedArray::fromPHP</methodname></member> | ||
<member><link xlink:href="&url.mongodb.docs.extendedjson;">MongoDB Extended JSON</link></member> | ||
<member><link xlink:href="&url.mongodb.docs.bson;">BSON Types</link></member> | ||
</simplelist> | ||
</refsect1> | ||
|
||
</refentry> | ||
<!-- Keep this comment at the end of the file | ||
Local variables: | ||
mode: sgml | ||
sgml-omittag:t | ||
sgml-shorttag:t | ||
sgml-minimize-attributes:nil | ||
sgml-always-quote-attributes:t | ||
sgml-indent-step:1 | ||
sgml-indent-data:t | ||
indent-tabs-mode:nil | ||
sgml-parent-document:nil | ||
sgml-default-dtd-file:"~/.phpdoc/manual.ced" | ||
sgml-exposed-tags:nil | ||
sgml-local-catalogs:nil | ||
sgml-local-ecat-files:nil | ||
End: | ||
vim600: syn=xml fen fdm=syntax fdl=2 si | ||
vim: et tw=78 syn=sgml | ||
vi: ts=1 sw=1 | ||
--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
reference/mongodb/bson/packedarray/tocanonicalextendedjson.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- $Revision$ --> | ||
<refentry xml:id="mongodb-bson-packedarray.tocanonicalextendedjson" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<refnamediv> | ||
<refname>MongoDB\BSON\PackedArray::toCanonicalExtendedJSON</refname> | ||
<refpurpose>Returns the Canonical Extended JSON representation of the BSON array</refpurpose> | ||
</refnamediv> | ||
|
||
<refsect1 role="description"> | ||
&reftitle.description; | ||
<methodsynopsis> | ||
<modifier>final</modifier> <modifier>public</modifier> <type>string</type><methodname>MongoDB\BSON\PackedArray::toCanonicalExtendedJSON</methodname> | ||
<void/> | ||
</methodsynopsis> | ||
<para> | ||
Converts the BSON array to its | ||
<link xlink:href="&url.mongodb.specs.extendedjson;#canonical-extended-json-example">Canonical Extended JSON</link> | ||
representation. The canonical format prefers type fidelity at the expense of | ||
concise output and is most suited for producing output that can be converted | ||
back to BSON without any loss of type information (e.g. numeric types will | ||
remain differentiated). | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="parameters"> | ||
&reftitle.parameters; | ||
&no.function.parameters; | ||
</refsect1> | ||
|
||
<refsect1 role="returnvalues"> | ||
&reftitle.returnvalues; | ||
<para> | ||
Returns a string containing the | ||
<link xlink:href="&url.mongodb.specs.extendedjson;#canonical-extended-json-example">Canonical Extended JSON</link> | ||
representation of the BSON array. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="examples"> | ||
jmikola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
&reftitle.examples; | ||
<example> | ||
<title><methodname>MongoDB\BSON\PackedArray::toCanonicalExtendedJSON</methodname> example</title> | ||
<programlisting role="php"> | ||
<![CDATA[ | ||
<?php | ||
$array = [ | ||
'foo', | ||
123, | ||
4294967295, | ||
new MongoDB\BSON\ObjectId('56315a7c6118fd1b920270b1'), | ||
]; | ||
$packedArray = MongoDB\BSON\PackedArray::fromPHP($array); | ||
echo $packedArray->toCanonicalExtendedJSON(), "\n"; | ||
?> | ||
]]> | ||
</programlisting> | ||
&example.outputs; | ||
<screen> | ||
<![CDATA[ | ||
[ "foo", { "$numberInt" : "123" }, { "$numberLong" : "4294967295" }, { "$oid" : "56315a7c6118fd1b920270b1" } ] | ||
]]> | ||
</screen> | ||
</example> | ||
</refsect1> | ||
|
||
<refsect1 role="seealso"> | ||
&reftitle.seealso; | ||
<simplelist> | ||
<member><methodname>MongoDB\BSON\PackedArray::fromJSON</methodname></member> | ||
<member><methodname>MongoDB\BSON\PackedArray::toRelaxedExtendedJSON</methodname></member> | ||
<member><function>MongoDB\BSON\toCanonicalExtendedJSON</function></member> | ||
<member><link xlink:href="&url.mongodb.specs.extendedjson;">Extended JSON Specification</link></member> | ||
<member><link xlink:href="&url.mongodb.docs.bson;">BSON Types</link></member> | ||
</simplelist> | ||
</refsect1> | ||
|
||
</refentry> | ||
<!-- Keep this comment at the end of the file | ||
Local variables: | ||
mode: sgml | ||
sgml-omittag:t | ||
sgml-shorttag:t | ||
sgml-minimize-attributes:nil | ||
sgml-always-quote-attributes:t | ||
sgml-indent-step:1 | ||
sgml-indent-data:t | ||
indent-tabs-mode:nil | ||
sgml-parent-document:nil | ||
sgml-default-dtd-file:"~/.phpdoc/manual.ced" | ||
sgml-exposed-tags:nil | ||
sgml-local-catalogs:nil | ||
sgml-local-ecat-files:nil | ||
End: | ||
vim600: syn=xml fen fdm=syntax fdl=2 si | ||
vim: et tw=78 syn=sgml | ||
vi: ts=1 sw=1 | ||
--> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.